question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Authorization header not excluded sometimes

See original GitHub issue

Hi, Thanks for creating this excellent module. I’m new to Angular so apologies if this is not an issue and just me being an idiot.

I’m having a problem excluding the Authorization header in my requests. (preflight fails when Authorization header is included so I need it removed).

I’ve modified the given keycloak-heroes example to replicate my problem. I’ve added a span with on click event in the home component which calls HeroesService which makes a POST request to the URL I want excluded. I’ve also updated app-init.js with my url/realm/clientId and added the URL I want excluded.

Problem is the Authorization header is being included sometimes. First time I click the element - no Authorization header - second time Authorization header - third time no header etc…

I tried latest v1.2.3 and also tried various regex with the excluded URL but no luck.

If I remove keycloak from the providers in app.modules.ts the code works fine - as a test just in case it’s my lack of Angular causing the issue.

Here’s the changes I made so you can see what I’m talking about.

home.component.html:

I just added a span before the final div:

<span (click)="test()">TEST</span>

home.component.ts:

  test() {
    this.heroesService.graphQl('some query').subscribe((r) => { console.log(r); });
  }

heroes.service.ts:

  graphQl(query): any {
    const headers = new HttpHeaders({
      'X-COMPANY-API-Key' : 'xxx',
      'Content-Type' : 'application/json'
    });
    const options = { headers: headers };
    return this.http.post('https://api.COMPANY.com/graphql', query, options);
  }

app-init.ts:

  config: {
    url: 'https://login.COMPANY.com/auth/',
    realm: 'COMPANY-REALM',
    clientId: 'COMPANY-CLIENTID'
  },
  initOptions: {
    onLoad: 'login-required',
    checkLoginIframe: false
  },
  bearerExcludedUrls: [
    'https://api.COMPANY.com/graphql'
  ]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
angular101commented, Jan 30, 2018

@mauriciovigolo Brilliant I look forward to the new release! Thanks for all your hard work.

1reaction
angular101commented, Jan 30, 2018

Hi @mauriciovigolo,

Thanks for rapid response very much appreciated.

I tried using 'graphql' and I still get same problem - it includes the auth header every second time.

if I use '.*' it works and never includes the auth header.

I wonder if this has any bearing?: https://stackoverflow.com/questions/3811890/javascript-regular-expression-fails-every-other-time-it-is-called

Read more comments on GitHub >

github_iconTop Results From Across the Web

The "Authorization" header is not sent in OPTIONS call by the ...
Exclude user credentials". I need to change the server in a way to response to OPTIONS call without requiring Authorization header?
Read more >
WWW-Authenticate - HTTP - MDN Web Docs
This new request uses the Authorization header to supply the credentials to the server, encoded appropriately for the selected "challenge" ...
Read more >
Why authorization header not included in request ? - Auth0
The reason for that is this request from the browser is not including the Authorization header, unlike postman.
Read more >
Authentication Header - an overview | ScienceDirect Topics
Authentication Header · Data integrity Calculates a hash of the entire IP packet, including the original IP header (but not variable fields such...
Read more >
Authenticating Requests (AWS Signature Version 4)
If any request component received by Amazon S3 does not match the component ... HTTP Authorization header – Using the HTTP Authorization header...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found