Skip to main content

Spring security token based authentication example


Basic flow in Spring Security Token based Authentication


  1. For the first time you have to use HTTP basic authentication and then login (send username/password) and this will return the token.
  2. In subsequent request you will use this token for authentication.
  3. You will have to add a filter to the chain that will do that authentication based on a token.
You have to come up with a token format and encryption for same. You ideally need to keep an expiry for the token too, expiry along with username could be a part of the token.Use  cryptographic hash function like MD 5 and get hash of the whole Token.

Few Examples of Token based Authentication in Spring.