Tag: jwt feathersjs

如何在使用feathersjs响应NodeJs之前发送令牌jwt来validation?

我正在使用令牌jwt做pipe理仪表板。 我想用户只有login才能获得对中间件的访问权限。 我想这样做,如果他login,服务器显示主页,如果没有,然后他redirect到login页面。 下面是我的中间件index.js const auth = require('feathers-authentication'); const pupils = require('./pupils'); const login = require('./login'); const home = require('./home'); module.exports = function () { // Add your custom middleware here. Remember, that // in Express the order matters const app = this; // eslint-disable-line no-unused-vars app.use('/pupils.html', pupils()); app.use('/login.html', login()); app.use('/', home()); app.post('/login', auth.express.authenticate('local', { […]

将非用户字段添加到有效内容以用于JWT令牌

您好我正在寻找添加一个非用户字段的身份validation过程中的有效载荷,所以我可以包含在JWT令牌。 请求是这样的: { "scriptId": "script1", "password": "password", "userName": "user1" } configuration是这样的: "auth": { "local": { "usernameField" : "scriptId" }, "token": { "secret": "mysecret", "payload": ["scriptId","userName"], "expiresIn": "10min" }, "successRedirect": "/chat.html" } 我怎样才能传递userName参数,所以我可以在auth /令牌服务的前钩子检索它,所以我可以把它的hook.data 或者如果有更好的方法来做,只需让我知道。