daniel-cottone / Cerberus

A demonstration of a completely stateless and RESTful token-based authorization system using JSON Web Tokens (JWT) and Spring Security.
MIT License
477 stars 176 forks source link

where tokens are stored? #23

Closed kamilwlf closed 7 years ago

kamilwlf commented 7 years ago

where tokens are stored?

ghost commented 7 years ago

For the server, the tokens aren't stored anywhere. Checking to see if a provided token is valid is not accomplished by checking some store of previously created tokens, but rather:

The above steps ensure that a token is valid and the appropriate permissions are given for the request associated with that token. One consideration is that this design does not allow for the revocation of tokens; if that is required then some kind of token store would need to be created.

If the question is where should the token be stored on the client side, the answer is wherever that is reasonably secure. For example in the browser you could store them in a secure cookie or local storage, or on an iOS app you could store them in the keychain.