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

Conditionnally configure JWT expireIn? #776

Closed
DrakaSAN opened this issue Jan 8, 2018 · 3 comments
Closed

Conditionnally configure JWT expireIn? #776

DrakaSAN opened this issue Jan 8, 2018 · 3 comments

Comments

@DrakaSAN
Copy link

DrakaSAN commented Jan 8, 2018

I have a use case where some users will need a JWT with a longer timeout. I know that in a standard app, I can edit src/authentication.js to add a expireIn flag, but this result in all JWT having the extended validation time.

Is there a way, for example in a hook, to change the expireIn option for just that request? By manually searching inside it, the only thing I found is hook.app.authentication.jwt.expireIn, which doesn't look like what I want.

@daffl
Copy link
Member

daffl commented Jan 8, 2018

You should be able to set JWT options dynamically in params.jwt in a before createhook:

app.service('authentication').hooks({
  before: {
    create(context) {
      context.params.jwt.expiresIn = '2d';
    }
  }
});

@DrakaSAN
Copy link
Author

DrakaSAN commented Jan 9, 2018

It did work, thanks a lot :)

@DrakaSAN DrakaSAN closed this as completed Jan 9, 2018
@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants