-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add a margin to the automatic JWT refresh #33
Conversation
By configuring `refreshMargin` the JWT gets refreshed that many seconds before the current token expires.
I've had a go at implementing the feature I suggested in #32 by adding a configurable parameter that defaults to 0. It might actually make sense to default to some value (10 seconds? A minute? 5 minutes?), but I'm just getting my feet wet with JSON Web Tokens, so I might be mistaken. |
+1 on this one. All of my refresh requests keep getting cancelled as the JWT is expired by the time the refresh makes the requests. Great work @jdhoek |
I definitely thought this would have been an issue. @erichonkanen haven't you run into this? This looks pretty good as is to me, not too sure about the actual name for the setting |
@jpadilla I have not run into this issue in any of the projects Ive used this with. Two of these projects are deployed to heroku currently in an ember-cli client/django backend setup with proxy. The only thing I can think of for me is that I have JWT_LEEWAY set to 3 seconds on the django jwt side. That said it seems logical to have something like this. cheers |
@validkeys have you tried setting a leeway on the server side? that is the most likely reason you ran into this and I didn't |
@jpadilla I'm implementing a Java API that serves up and refreshes JWT. I considered giving the timeout some leeway server-side, but that would encourage an API where the client sends expired or very nearly expired tokens to the server. That doesn't feel quite right in terms of a clean API, although for all practical purposes both approaches should work equally fine. |
This conforms with the term other JWT libraries use.
Thanks for the 👍 vote of confidence. @jpadilla |
@erichonkanen I didn't but I just tried it out and that works well for me. Having that hint as part of the documentation would be great for JWT noobs (like me) (Best Practice would be to include a leeway in your JWT's decode method server side). |
Add a margin to the automatic JWT refresh
Thanks! |
By configuring
refreshMargin
the JWT gets refreshed that many secondsbefore the current token expires.
PR for #32.