akveo / akveo/nebular

NbAuthSimpleInterceptor does not add `Bearer` prefix to HTTP header

未关闭
#3,151 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
8.1k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

### Issue type

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

* [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:
```typescript
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](https://stackoverflow.com/questions/56971213) 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
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。