我有来自两个不同客户端(角度客户端和 node.js 羽毛客户端)的传入连接,我希望他们使用两个不同的身份验证端点(基于两个单独表中的数据)。一个应该针对 /users 服务进行身份验证,其他人应该针对 /users2 服务进行身份验证。
如何做到这一点?
这是它与一个身份验证端点一起工作的方式:
// default.json
"authentication": {
"secret": "<secret>",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "users",
"jwt": {
"header": {
"typ": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
}
}
// authentication.js
const authentication = require('@feathersjs/authentication');
const jwt = require('@feathersjs/authentication-jwt');
const local = require('@feathersjs/authentication-local');
module.exports = function (app) {
const config = app.get('authentication');
app.configure(authentication(config));
app.configure(jwt());
app.configure(local());
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(config.strategies),
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
};
谢谢!