How Does Token Authentication Work?

Token-based authentication works through a five-step process:

  1. Request
  2. Verification
  3. Token submission
  4. Storage
  5. Expiration

Token-based authentication proves that the user has been provided access to applications, websites, and resources without having to verify their identity every time they navigate to a new site. Websites can also add additional layers of security beyond traditional passwords without forcing users to repeatedly prove their identity, which improves both user experience and security.

What is an Authentication Token?

All authentication tokens provide users with access to a device or application. However, there are several different types of tokens that can be used to verify a user’s identity, from software tokens to physical tokens. Here are a few common types of tokens that are being used by developers to authenticate users or service accounts today.

Hardware Tokens (USB Tokens)

Hardware tokens, sometimes called authentication or security tokens, are physical devices that enable the authorization of users to access protected networks. The purpose of a hardware token is to add a layer of security via two-factor or multi-factor authentication. The token user links the token to the system or service they want to access.

Hardware tokens are designed for seamless user experience and customizability which allows them to be available in multiple forms. The most common types of tokens are key fobs, USBs, and wireless tokens. Hardware tokens can be divided into three categories:

  • Contactless – a contactless token doesn’t require you to enter an access code or connect to a device. This type of token uses a wireless connection to access the system which may grant or deny access based on the credentials associated with the connections.
  • Disconnected – a disconnected token doesn’t need to be physically inserted into the system being accessed. It simply works by setting up the device to generate a one-time access code, which serves as part of multi-factor authentication. A disconnected token will likely be a mobile device such as a smartphone or tablet.
  • Connected – a connected token must be physically connected to a system in order to enable access. The token is scanned by a reader, which receives any relevant authentication credentials. This could be a USB token or a key fob.

JSON Web Tokens (JWT)

A JSON Web Token is an open standard (RFC 7519). It defines a simple, self-contained method for transmitting information between parties securely. A JWT standard uses JavaScript Object Notation (JSON) objects to transmit tokens between parties. These tokens can be used for authentication, and for the transfer of additional information about the user or account.

Because a JWT is so small, they can be sent as URL’s, POST parameters, or HTTP headers, and can be transmitted quickly. The JWT contains all the necessary information about the entity, to avoid multiple queries to the database. The JWT receiver doesn’t need to call the server to validate the token.

A JWT is composed of three parts:

  • A header – includes the type of token and the encryption algorithm it uses
  • A payload – provides authentication credentials and other information about the user or account
  • A signature – includes a cryptographic key that can be used to validate the authenticity of the information in the payload

One Time Password (OTP) Tokens

One-time password (OTP) tokens are secure hardware devices or software programs that can generate one-time passwords. Most commonly, these are personal identification numbers (PIN), numeric codes between 4-12 digits.

Smartphones are commonly used to generate or receive one-time passwords. Once a user proves ownership of their phone, they can use an authenticator app that generates OTP passwords—in this case the phone serves as a code generator. Alternatively, OTPs can be sent to the device by SMS.

One-time password tokens enhance existing identity and password systems by adding dynamically generated credentials. Depending on the provider, OTP tokens generate PINs either synchronously or asynchronously:

  • Synchronous tokens – use your private key and the current time to create a one-time password.
  • Asynchronous tokens – use Challenge Response Authentication Mechanism (CRAM), a group of protocols in which the server presents a challenge, and the token must generate the correct answer.

API Tokens

API tokens are used as unique identifiers of an application requesting access to your service. The service then generates an API token for the application to use when requesting your service. The API Token can then be matched with the one you have stored to authenticate and provide access.
API tokens have gained popularity as they have replaced the unsafe practice of sending username and password combinations over HTTP.

How Do Tokens Work?

Token-based authentication works through a five-step process:

  1. Request: The user logs in to a service using their login credentials, which issues an access request to a server or protected resource
  2. Verification: The server verifies the login information to determine that the user should have access. This involves checking the password entered against the username provided
  3. Token submission: The server generates a secure, signed authentication token for the user for a specific period of time
  4. Storage: The token is transmitted back to the users browser, which stores it for access to future website visits. When the user moves on to access a new website, the token is decoded and verified.
  5. Expiration: The token will remain active until the user logs out or closes the server

This token-based process proves that the user has been provided access to applications, websites, and resources without having to verify their identity every time they navigate to a new site. Websites can add additional layers of security beyond traditional passwords without forcing users to repeatedly prove their identity, which improves both user experience and security.

An authentication token is formed of three key components: the header, payload, and signature.

Header – The header defines the token type being used, as well as the signing algorithm involved.
Payload – The payload is responsible for defining the token issuer and the token’s expiration details. It also provides information about the user plus other metadata.
Signature – The signature verifies the authenticity of a message and that a message has not changed while in transit.

These tokens are the digital version of a stamped ticket to an event. The user or bearer of the token is provided with an access token to a website until they log out or close the service.

Is Token Based Authentication Secure?

As cybercrime becomes more sophisticated, managed service providers must continuously update their security techniques and policies. Due to the increase in attacks that target credentials via methods like phishing, or brute force and dictionary attacks, authentication can no longer rely on passwords alone.

When combined with additional authentication techniques, token-based authentication can create a more complex barrier to prevent sophisticated hackers from exploiting stolen passwords. Tokens are only retrievable from the unique device that created them such as a smartphone or key fob, making them a highly effective authorization methodology today.
It should be noted that while there are many advantages to authentication token platforms, some risk always remains. Tokens that are housed in mobile devices are convenient to use but may be exposed through device vulnerabilities. If the tokens are via SMS, they can easily be intercepted in transit. If a device is lost or stolen, a malicious actor can gain access to the tokens stored in it.

Token authentication should be considered as one component in a two-factor or multi-factor authentication strategy.

Advantages and Disadvantages of Token-Based Authentication

Advantages

  • Tokens are stateless: Authentication tokens are created by an authentication service and contain information that enables a user to verify their identity without entering login credentials.
  • Tokens expire: When a user finishes their browsing session and logs out of the service, the token they were granted is destroyed. This ensures that users’ accounts are protected and are not at risk of cyberattacks.
  • Tokens are encrypted and machine-generated: Token-based authentication uses encrypted, machine-generated codes to verify a user’s identity.
  • Tokens streamline the login process: Authentication tokens ensure that users do not have to re-enter their login credentials every time they visit a website.
  • Tokens add a barrier to prevent hackers: A 2FA barrier to prevent hackers from accessing user data and corporate resources.

 

Disadvantages

  • Single key: JWTs rely on a single key. If that key is compromised, the entire system is at risk.
  • Complexity: These tokens aren’t simple to understand. If a developer doesn’t have a strong knowledge of cryptographic signature algorithms, they could inadvertently put the system at risk.
  • Limitations: You can’t push messages to all clients, and you can’t manage clients from the server side.

Token-Based Authentication Best Practices

Authentication tokens are meant to enhance your security protocols and keep your server safe. To make token work effectively, you need to build your processes with safety in mind.

Your authentication tokens should be:

  • Private: Users can’t share token authentication devices or pass them around between departments.
  • Secure: Communication between the token and your server must be secure via HTTPS connections.
  • Tested: Run periodic token tests to ensure that your system is secure and functioning properly
    Appropriate: Pick the right token type for your individual use case

    Don’t take your authentication token decision lightly. Do your homework, ask your peers, and ensure that you’re doing the best job you can for your company.

Start your free trial today. No credit card required.

Sign up and Go