DEV Community

Ramu Ummadishetty
Ramu Ummadishetty

Posted on

1

Token vs Session Based Authentication

Session based authentication

  • In session based authentication server stores the user information and each users has a corresponding session ID to validate them.
  • Session based or token based authentication is a process that allows the server to handle multiple requests from the same user without asking the user to login again
  • When user log out server ends the session or invalidate the token and revokes the authentication

Most of the time this session ID and Token is shared to browser in form of HTTP cookie. For each request this cookie is included for validating the user

Token based Authentication

  • Token-based authentication system stores this info directly in some sort of token.
  • Using token server decodes it for user identity and it reduces the process of storing the session ID's

Token auth flow

  • Users login with their credentials.
  • Those credentials are provided to server for validation and if those are valid a signed token will be given to user
  • For each request and response this signed token is included for user identity
  • This token can be included in headers or cookies
  • Every time server upon validating the token shares the resources for user

Token security

  • Integrity of token is protected by signing the token and verifying its signature each time when it arrives at server
  • Server uses secret key to generate the special string for signing the token. If any user or third party tampers the token signature will be not valid

Check for JSON Web Tokens here

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay