Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NbAuthSimpleInterceptor does not add Bearer prefix to HTTP header #3151

Open
1 of 2 tasks
willydee opened this issue Dec 25, 2022 · 0 comments
Open
1 of 2 tasks

NbAuthSimpleInterceptor does not add Bearer prefix to HTTP header #3151

willydee opened this issue Dec 25, 2022 · 0 comments

Comments

@willydee
Copy link

willydee commented Dec 25, 2022

Issue type

I'm submitting a ... (check one with "x")

  • bug report
  • feature request

Issue description

Current behavior:
Using NbPasswordAuthStrategy and the accompanying NbAuthSimpleInterceptor, the received token is inserted as HTTP header like so:
Authorization: 3b023126-a007-422e-9838-839871aae08b

Expected behavior:
I would need it to be:
Authorization: Bearer 3b023126-a007-422e-9838-839871aae08b

Steps to reproduce:
I generally followed the tutorial for NbPasswordAuthStrategy in the Nebular vnext Docs

Related code:
As a workaround I managed to configure a custom getter, like so:

NbAuthModule.forRoot({
  strategies: [
    NbPasswordAuthStrategy.setup({
      token: {
        key: 'token',
        getter: (_module: string, response: HttpResponse<{ token: string }>) =>
          `Bearer ${response.body?.token ?? ''}`,
      },
      // ...
    }),
  ],
});

Other information:

There is a (quite dated) Stackoverflow issue describing a similar issue with NbAuthJWTInterceptor, where the Bearer prefix is added in a hardcoded way instead. I guess it would be useful to generally make this prefix configurable (with sensible default that won't break existing apps).

npm, node, OS, Browser

Node v16.19.0
yarn: 1.22.19  
OS: EndeavourOS/ArchLinux x64 (rolling)
Browser: Firefox 108.0.1

Angular, Nebular

@angular/core: 15.0.0
@nebular/auth: 10.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant