Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Open In App
Next Article:
How does the Token-Based Authentication work ?
Next article icon

How does the Token-Based Authentication work ?

Last Updated : 13 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Digital transformation brings security concerns for users to protect their identity from bogus eyes. According to US Norton, on average 8 lakh accounts are being hacked every year. There is a demand for high-security systems and cybersecurity regulations for authentication.  

Traditional methods rely on single-level authentication with username and password to grant access to the web resources. Users tend to keep easy passwords or reuse the same password on multiple platforms for their convenience. The fact is, there is always a wrong eye on your web activities to take unfair advantage in the future. 

Due to the rising security load, two-factor authentication (2FA) come into the picture and introduced Token-based authentication. This process reduces the reliance on password systems and added a second layer to security. Let’s straight jump on to the mechanism.

But first of all, let’s meet the main driver of the process: a T-O-K-E-N !!!

What is an Authentication Token?

A Token is a computer-generated code that acts as a digitally encoded signature of a user. They are used to authenticate the identity of a user to access any website or application network.

A token is classified into two types: A Physical token and a Web token. Let’s understand them and how they play an important role in security.

  • Physical token: A Physical token use a tangible device to store the information of a user. Here, the secret key is a physical device that can be used to prove the user's identity. Two elements of physical tokens are hard tokens and soft tokens. Hard tokens use smart cards and USB to grant access to the restricted network like the one used in corporate offices to access the employees. Soft tokens use mobile or computer to send the encrypted code (like OTP) via authorized app or SMS.
  • Web token: The authentication via web token is a fully digital process. Here, the server and the client interface interact upon the user's request. The client sends the user credentials to the server and the server verifies them, generates the digital signature, and sends it back to the client. Web tokens are popularly known as JSON Web Token (JWT), a standard for creating digitally signed tokens.

A token is a popular word used in today's digital climate. It is based on decentralized cryptography. Some other token-associated terms are Defi tokens, governance tokens, Non Fungible tokens, and security tokens. Tokens are purely based on encryption which is difficult to hack.  

What is a Token-based Authentication?

Token-based authentication is a two-step authentication strategy to enhance the security mechanism for users to access a network. The users once register their credentials, receive a unique encrypted token that is valid for a specified session time. During this session, users can directly access the website or application without login requirements. It enhances the user experience by saving time and security by adding a layer to the password system.

A token is stateless as it does not save information about the user in the database. This system is based on cryptography where once the session is complete the token gets destroyed. So, it gets the advantage against hackers to access resources using passwords.  

The most friendly example of the token is OTP (One Time password) which is used to verify the identity of the right user to get network entry and is valid for 30-60 seconds. During the session time, the token gets stored in the organization's database and vanishes when the session expired.  

Let's understand some important drivers of token-based authentication-

  • User: A person who intends to access the network carrying his/her username & password.
  • Client-server: A client is a front-end login interface where the user first interacts to enroll for the restricted resource.
  • Authorization server: A backend unit handling the task of verifying the credentials, generating tokens, and send to the user.
  • Resource server: It is the entry point where the user enters the access token. If verified, the network greets users with a welcome note.

How does Token-based Authentication work?

Token-based authentication has become a widely used security mechanism used by internet service providers to offer a quick experience to users while not compromising the security of their data. Let's understand how this mechanism works with 4 steps that are easy to grasp.

How Token-based Authentication works?

1. Request: The user intends to enter the service with login credentials on the application or the website interface. The credentials involve a username, password, smartcard, or biometrics

2. Verification: The login information from the client-server is sent to the authentication server for verification of valid users trying to enter the restricted resource. If the credentials pass the verification the server generates a secret digital key to the user via HTTP in the form of a code. The token is sent in a JWT open standard format which includes-

  • Header: It specifies the type of token and the signing algorithm.
  • Payload: It contains information about the user and other data
  • Signature: It verifies the authenticity of the user and the messages transmitted.

3. Token validation: The user receives the token code and enters it into the resource server to grant access to the network. The access token has a validity of 30-60 seconds and if the user fails to apply it can request the Refresh token from the authentication server. There’s a limit on the number of attempts a user can make to get access. This prevents brute force attacks that are based on trial and error methods.  

4. Storage: Once the resource server validated the token and grants access to the user, it stores the token in a database for the session time you define. The session time is different for every website or app. For example, Bank applications have the shortest session time of about a few minutes only.

So, here are the steps that clearly explain how token-based authentication works and what are the main drivers driving the whole security process. 

Note: Today, with growing innovations the security regulations are going to be strict to ensure that only the right people have access to their resources. So, tokens are occupying more space in the security process due to their ability to tackle the store information in the encrypted form and work on both website and application to maintain and scale the user experience.  Hope the article gave you all the know-how of token-based authentication and how it helps in ensuring the crucial data is being misused. 


Next Article
How does the Token-Based Authentication work ?

K

kiranjyotkaur
Improve
Article Tags :
  • Ethical Hacking
  • Geeks-Premier-League-2022

Similar Reads

    Session vs Token Based Authentication
    The Session and Token-based Authentication methods are used to make a server trust any request sent by an authenticated user over the internet. In this way, a user can interact with their account without continually specifying their credentials. These methods are usually used for different purposes.
    5 min read
    How Does Certificate-Based Authentication Work?
    Certificate-Based Authentication is a cryptographic technique that enables secure identification of one computer by another across a network connection. It uses a public-key certificate. This authentication system confirms a user's or device's identity using digital certificates issued by a trusted
    10 min read
    How Does Two-Factor Authentication (2FA) Work?
    Two-factor authentication (2FA) is a security system that requires two distinct forms of identification in order to access something. Two-factor authentication can be used to strengthen the security of an online account, a smartphone, or even a door. 2FA does this by requiring two types of informati
    8 min read
    Session-Based Authentication vs. JSON Web Tokens (JWTs) in System Design
    Authentication is essential for websites and apps to verify users' identities. It's similar to showing your ID before entering a secured place or using a service online. There are two main ways to do this: Session-Based Authentication and JSON Web Tokens (JWTs). Session-based authentication creates
    8 min read
    What is Firebase Authentication
    Firebase Authentication is a powerful backend service offered by Google Firebase, designed to speed up the user authentication process in applications. Supporting various authentication methods, such as email/password, phone number, and social logins, Firebase Authentication ensures secure user auth
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences