我有来自两个不同客户端(角度客户端和node.js feathers客户端)的传入连接,我希望他们使用两个不同的身份验证端点(基于两个单独表中的数据)。一种应该针对/ 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')
]
}
});
};
谢谢!