Lexikjwtauthenticationbundle: Set token to invalid status

Created on 4 Apr 2015  路  5Comments  路  Source: lexik/LexikJWTAuthenticationBundle

Hi,

I'm french so sorry for my english.
How can I set a token to a invalidat status ?

(En fran莽ais : Je voudrais que le token devienne invalide quand je le souhaite, est-ce possible ?)

Thanks

Most helpful comment

Right now there really is no easy way to invalidate a particular token, as it is not part of the JWT specification. But if you really need to, some solutions are presented in this this thread.

Look at this cookbool entry and the IP flag examples, you should be able to customize the token validation by using the Events::JWT_CREATED and Events::JWT_DECODED events.

You could add a property to your user, let's say hash, and add it to the token payload and check its validity when your application receives the token back. When you need to invalidate a particular token, change its user hash value and the token won't work anymore.

Let me know if it helps.

All 5 comments

Hi,

Do you want to be able to invalidate just one particular token or every still valid token at once ?

Regards.

Thanks for your quickly response,

Just one

Right now there really is no easy way to invalidate a particular token, as it is not part of the JWT specification. But if you really need to, some solutions are presented in this this thread.

Look at this cookbool entry and the IP flag examples, you should be able to customize the token validation by using the Events::JWT_CREATED and Events::JWT_DECODED events.

You could add a property to your user, let's say hash, and add it to the token payload and check its validity when your application receives the token back. When you need to invalidate a particular token, change its user hash value and the token won't work anymore.

Let me know if it helps.

Thanks, the answer with hash is ok for me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Walkoss picture Walkoss  路  4Comments

garak picture garak  路  5Comments

rolandrajko picture rolandrajko  路  3Comments

AlexDupreWeb picture AlexDupreWeb  路  4Comments

reducio picture reducio  路  4Comments