The Wayback Machine - https://web.archive.org/web/20220309202941/https://github.com/jwt/ruby-jwt/issues/256
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

Get new token if curren token expired #256

Closed
ViTVetal opened this issue Mar 14, 2018 · 5 comments
Closed

Get new token if curren token expired #256

ViTVetal opened this issue Mar 14, 2018 · 5 comments

Comments

@ViTVetal
Copy link

@ViTVetal ViTVetal commented Mar 14, 2018

I created rails project as api for iOS and Android apps. I want use jwt. I think that timeless tokens - it is bad approach. So if the token expires, the client needs to re-login, which is unacceptable UX in my case.
How should I get out of this situation? Should I save login and password and perfrom auto sign in if token expires? (I think it is bad approach too)
Does your library support something like refresh token?

@ab320012
Copy link
Contributor

@ab320012 ab320012 commented Mar 14, 2018

I would set the token expiration to an arbitrarily long amount

@ViTVetal
Copy link
Author

@ViTVetal ViTVetal commented Mar 14, 2018

@ab320012 I think it is bad practice. In this case hacker will be able use stolen token long time until token expires

@excpt
Copy link
Member

@excpt excpt commented Mar 14, 2018

Hi @ViTVetal,

this is probably an answer you may not want to read but this is a complex question with no clear answer.

JWT by itself does not solve that problem for you. It provides a token format that you can verify by a given rule set. You should look into OAuth which is based upon JWT. OAuth servers provide an refresh token after the initial authentication to give you an easy way to refresh short lived JWTs. IMHO the JWT expiration should be a short amount of time. At most days but preferable hours or minutes depending on the situation and many other factors.

You may have a look at doorkeeper. https://github.com/doorkeeper-gem/doorkeeper

Another way to use JWT in your app is to integrate OAuth providers like Google/Firebase, Facebook, Twitter, 0Auth, {insert your provider of choice here}, etc.

@excpt
Copy link
Member

@excpt excpt commented Mar 14, 2018

@ViTVetal
Copy link
Author

@ViTVetal ViTVetal commented Mar 15, 2018

@excpt Thank you! It is important for me to hear the answer from the owner of repository. I'll look at links

@excpt excpt closed this Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants