如何加入 feathersjs jwt 与猫鼬?
How to join feathersjs jwt with mongoose?
我尝试使用保存在 mongodb 中的本地用户登录我的应用程序。我的应用程序使用 feathersjs 在 Node.js 上运行。 运行 应用程序后,我收到如下错误:
Error: You must provide a 'header' in your authentication configuration or pass one explicitly
这是我的配置文件:
{
"host": "localhost",
"port": 3030,
"public": "../public/",
"paginate": {
"default": 10,
"max": 50
},
"authentication": {
"secret": "My secret key",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "authentication",
"jwt": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
}
},
"mongodb": "mongodb://localhost:27017/mydb"
}
这有什么问题吗?
这是 feathers-cli
最新版本中的错误,已在 v2.3.7
中修复,因此请确保 feathers --version
显示该版本。在现有应用程序中,您可以通过将 src/app.js
从
更改为来修复错误消息
app.configure(jwt(config.jwt));
app.configure(local(config.local));
到
app.configure(jwt());
app.configure(local());
我尝试使用保存在 mongodb 中的本地用户登录我的应用程序。我的应用程序使用 feathersjs 在 Node.js 上运行。 运行 应用程序后,我收到如下错误:
Error: You must provide a 'header' in your authentication configuration or pass one explicitly
这是我的配置文件:
{
"host": "localhost",
"port": 3030,
"public": "../public/",
"paginate": {
"default": 10,
"max": 50
},
"authentication": {
"secret": "My secret key",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "authentication",
"jwt": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
}
},
"mongodb": "mongodb://localhost:27017/mydb"
}
这有什么问题吗?
这是 feathers-cli
最新版本中的错误,已在 v2.3.7
中修复,因此请确保 feathers --version
显示该版本。在现有应用程序中,您可以通过将 src/app.js
从
app.configure(jwt(config.jwt));
app.configure(local(config.local));
到
app.configure(jwt());
app.configure(local());