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

Destroying the active token #71

Open
emresaracoglu opened this issue Oct 20, 2021 · 1 comment
Open

Destroying the active token #71

emresaracoglu opened this issue Oct 20, 2021 · 1 comment

Comments

@emresaracoglu
Copy link

Hello,

I want to expire/kill a currently active Token. Is this possible?

Thank you for your work!

@teckel12
Copy link

Old question, but I figured I'd answer. A JWT token typically isn't stored and therefore can't be revoked. You can, however, store valid tokens (for example in a database for the particular user) which can then be validated on each access. This kind of defeats one of the benefits of a JWT token (low server-side load as it doesn't require a database to validate), but does accomplish your goal.

The more typical way this is accomplished is to create both a standard JWT token and a refresh token, which is only sent when refreshing the JWT token. This refresh token is stored in a database and validated. This way, you can revoke a user by deleting the refresh token from the database. This allows for the low-overhead and no database needed benefits of a JWT token, but you can revoke a user's connection by deleting the refresh token.

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

No branches or pull requests

2 participants