Authentication Token Strategies

This section describes the authentication token strategies that can be configured for a Tenant.
The duration values shown in the following diagrams are provided only as examples, as they are fully configurable.
Each strategy is explained in terms of its session duration, token validity periods, and associated advantages.

Access Token Only Strategy

📘

The Access Token Only Strategy is enabled when the auth.jwt.refreshToken property of the TenantConfig object is not set (or it is set to null).

When a client logs in, the Gateway returns only an access token with a configured validity period. The client uses this access token to authorize requests to the Gateway.

In this strategy, the access token validity period is equal to the session duration. Once the access token expires, the client must log in again to obtain a new valid access token.


Access Token With Standard Refresh Token Strategy

📘

The Standard Refresh Token Strategy is enabled by setting to false the auth.jwt.refreshToken.enableRotation property of the TenantConfig object.

When a client logs in, the Gateway returns both an access token and a refresh token. The refresh token has a longer validity period (for example, one week or one month), while the access token has a much shorter validity period (for example, a few minutes).

When the access token expires, the client can use the still-valid refresh token to request a new access token from the Gateway. The Gateway validates the refresh token and, if it is valid, returns a new access token that the client can use to continue authorizing requests.

In this strategy, the session duration approximately corresponds to the validity period of the refresh token. If the refresh token expires while the access token is still valid, the client can continue using the access token until it expires. After both tokens have expired, the client must log in again to obtain a new valid access token and a new valid refresh token.

📘

The main security advantage of using refresh tokens with short-lived access tokens is that it reduces the impact of a compromised access token. Access tokens are sent with every authenticated request, making them more exposed. By keeping access tokens short-lived, the time window in which a stolen access token can be used by an attacker is significantly reduced, while refresh tokens allow the user session to remain active without requiring frequent logins.


Access Token with Refresh Token Rotation Strategy

📘

The Refresh Token Rotation Strategy is enabled by setting to true the auth.jwt.refreshToken.enableRotation property of the TenantConfig object.

When a client logs in, the Gateway returns both an access token and a refresh token. The refresh token has a longer validity period (for example, one week or one month), while the access token has a much shorter validity period (for example, a few minutes).

When the access token expires, the client can use the still-valid refresh token to request a token refresh from the Gateway. The Gateway validates the refresh token and, if it is valid, returns a new access token together with a new refresh token.

The new refresh token has the same absolute expiration date as the old refresh token.

The new refresh token must replace the current (old) refresh token. The old refresh token is automatically revoked by the Gateway and is not usable anymore. A revoked token is a token that can no longer be used, even if its configured validity period has not yet expired. This prevents a previously issued refresh token from being reused if it has been compromised or stolen.

Therefore, it is important to distinguish between the configured validity period of a refresh token and its effective lifetime:

  • configured validity period: it is the duration assigned to the token when it is issued.

  • effective lifetime: it is the period during which the token remains usable before it is revoked by the Gateway or expires. If the token is not revoked before its expiration, the effective lifetime is equal to its configured validity period. Otherwise, if the token is revoked before it expires, the effective lifetime is shorter than its configured validity period.

With refresh token rotation, each newly issued refresh token replaces and immediately revokes the previous one. As a result, the effective lifetime of an individual refresh token is typically much shorter than its configured validity period. In normal usage, where the client refreshes tokens whenever the access token expires, the effective lifetime of each refresh token is approximately comparable to the access token duration.

📘

In other words, the main advantage of refresh token rotation compared to the standard refresh token strategy is that it significantly reduces the average effective lifetime of individual refresh tokens. This reduces the time window in which a compromised refresh token can be used.

In this strategy, the session duration approximately corresponds to the configured validity period of the first refresh token issued during the initial login.

If the latest issued refresh token expires while the current access token is still valid, the client can continue using the access token until it expires. Once both the latest issued refresh token and the current access token have expired, the client must log in again to obtain a new valid access token and a new valid refresh token.


Did this page help you?