【发布时间】:2018-02-08 23:26:29
【问题描述】:
JWT 的 sub 声明是可选的,但 feathersjs-authentication 不允许我将其设置为空白字符串或将其删除。
我能够在hook 之前的authentication 中的有效负载中添加一个新值,但更改sub 或尝试将其删除不起作用。
app.service('/api/auth').hooks({
before: {
create: [
// You can chain multiple strategies
auth.hooks.authenticate(['jwt', 'local']),
hook => {
// I can add a new `SUB` value but this method doesn't work for `sub`
Object.assign(hook.params.payload, {SUB: hook.params.payload.userId})
}
],
...
我尝试将相同的更改添加到 after 挂钩,但这也不起作用。将sub 值设置为anonymous 对我来说似乎不合适。他们的文档甚至说:
subject: 'anonymous', // Typically the entity id associated with the JWT
但似乎没有一种直接的方法可以让 sub JWT 声明一个动态值。
【问题讨论】:
标签: feathersjs feathers-authentication