node.js - 无法使用羽毛身份验证进行身份验证
问题描述
我创建了羽毛 js 应用程序,然后使用添加了身份验证feather generate 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');
// Set up authentication with the secret
app.configure(authentication(config));
app.configure(jwt());
app.configure(local());
// The `authentication` service is used to create a JWT.
// The before `create` hook registers strategies that can be used
// to create a new valid JWT (e.g. local or oauth2)
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(config.strategies)
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
};
然后我将以下代码添加到app.js
const authentication = require('./authentication');
app.configure(authentication);
default.json看起来像这样
"authentication": {
"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"
}
}
当我localhost:3030/users
从邮递员向用户服务发送发布请求时,创建了新用户但是当我尝试localhost:3030/authentication
使用有效负载从邮递员发送发布请求时
{"strategy":"local","email":"user","password":"pass"}
我得到以下回应
{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"data": {
"message": "Invalid login"
},
"errors": {}
}
一切看起来都很好,但我无法让它工作,我一直在关注这个教程,可以帮助我吗?提前致谢。
解决方案
推荐阅读
- apache-camel - Camel netty4-http 在请求中设置了无效的主机 http 标头
- flutter - 有没有办法在一个容器中包含多个孩子?
- silverstripe - Silverstripe 4 silvershop-core paypal-expr. 税费和运费
- android - 使用此命令在移动设备中运行离子应用程序时出错(离子科尔多瓦运行安卓)
- android - Android 导航组件 - 在包含的模块图之间导航
- android - 在 android ExoPlayer 中添加用于播放加密 .m3u8 流的参数
- netbeans - Netbeans.conf:用户主页的变量是什么?
- javascript - 用户选择:没有在 Safari 中表现不同
- r - 如何使用带有复选框事件 Shiny 的 observeEvent
- javascript - 当我在 html 和 css 中向下滚动时,如何使图像位于菜单栏后面?