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

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

I would set the token expiration to an arbitrarily long amount

@ViTVetal
Copy link
Author

@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 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 commented Mar 14, 2018

An article you may want to read: https://medium.facilelogin.com/jwt-jws-and-jwe-for-not-so-dummies-b63310d201a3

@ViTVetal
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants