Mark As Completed Discussion

There are a few significant advantages to using token-based authentication:

  • Stateless, Scalable, and Decoupled: each token is self-contained, containing all the data required to check its validity
  • You can store additional data in the token itself - for example, roles, access privileges, and other data, as long as it is valid JSON data
  • Mobile ready - tokens are easy to implement in mobile and IoT applications
  • Easy to maintain
  • A token-based authentication approach with CORS enabled makes it easy to expose APIs to different services and domains

When it comes to disadvantages however, these are the ones to consider:

  • JWT tokens can be large in size
  • If the token is placed in the browser's local storage it can be prone to XSS attacks
  • Tokens cannot be used to authenticate a user in the background on the server since no session exists on the database level