【问题标题】:How to join feathersjs jwt with mongoose?如何将feathersjs jwt与猫鼬一起加入?
【发布时间】:2018-02-22 02:36:06
【问题描述】:

我尝试使用 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"
}

这有什么问题?

【问题讨论】:

    标签: node.js mongodb mongoose feathersjs feathers-authentication


    【解决方案1】:

    这是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());
    

    【讨论】:

    • 我在"header": "Authorization", 上更改了"jwt": { "header": { "type": "access" },,我的应用程序正在运行,但我不知道这是否是一个好的解决方案。昨天我重新安装了 npm 和 feathers-cli 但我的版本是 2.3.6 如何安装最新版本的 feathers-cli?
    • 我使用feathers-authentication,我的项目中没有像上面那样的任何行。
    • 好的,我现在有 2.3.7 版本。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-02-05
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 2017-11-01
    • 2019-04-13
    • 1970-01-01
    • 2019-12-12
    相关资源
    最近更新 更多