Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createJWT throws 'secret must provided' #437

Closed
whollacsek opened this Issue Mar 7, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@whollacsek
Copy link
Contributor

whollacsek commented Mar 7, 2017

The doc says app.passport.createJWT(payload, options) will pull from config automatically, but I'm getting secret must provided error when calling app.passport.createJWT(payload)

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Mar 7, 2017

@whollacsek please show your config and let us know the version numbers of the auth plugins used.

@whollacsek

This comment has been minimized.

Copy link
Contributor Author

whollacsek commented Mar 8, 2017

Looking at the source code of createJWT (https://github.com/feathersjs/feathers-authentication/blob/master/src/utils.js) the app config is not loaded, so I'm using hook.app.service('authentication').create({}) instead which works.

@Mattchewone

This comment has been minimized.

Copy link

Mattchewone commented Mar 10, 2017

@whollacsek You config should look something similar to this:

  "authentication": {
    "secret": "<TOKEN>",
    "strategies": [
      "jwt",
      "local"
    ],
    "path": "/authentication",
    "service": "users"
  },
@whollacsek

This comment has been minimized.

Copy link
Contributor Author

whollacsek commented Mar 10, 2017

@Mattchewone I didn't know it's necessary to setup "strategies": [ "jwt", "local" ] can you point me to the docs about this?

@Mattchewone

This comment has been minimized.

Copy link

Mattchewone commented Mar 10, 2017

I may be leading you down the wrong path @whollacsek I was reading the v1 docs - https://github.com/feathersjs/feathers-authentication/tree/master

If you are not using that then you can ignore my comment.

@whollacsek

This comment has been minimized.

Copy link
Contributor Author

whollacsek commented Mar 10, 2017

@Mattchewone I'm on v1, but the doc doesn't talk about setting "strategies": [ "jwt", "local" ] in the config files

@Mattchewone

This comment has been minimized.

Copy link

Mattchewone commented Mar 10, 2017

@whollacsek The strategies is just a preference for doing this:

const config = app.get('authentication');
auth.hooks.authenticate(config.strategies);

Looking at the authenticate init method strategies are not being used, I guess as each strategy needs to be initialised separately.

Do you have your config and your authenticate configuration?

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Mar 10, 2017

The docs are wrong. app.passport.createJWT and app.passport.verifyJWT needs options passed.

@whollacsek whollacsek closed this Mar 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.