diff --git a/api-management/authentication/jwt-authorization.mdx b/api-management/authentication/jwt-authorization.mdx
index 204ebbd09..a787e820a 100644
--- a/api-management/authentication/jwt-authorization.mdx
+++ b/api-management/authentication/jwt-authorization.mdx
@@ -1,6 +1,6 @@
---
title: "JWT Authorization"
-description: "How JWT authorization works in Tyk API Gateway."
+description: "Tyk Gateway's JWT Authorization process extracts user identity and applies security policies based on JWT claims for API access control."
keywords: "Authentication, Authorization, JWT, JSON Web Tokens, Claims, Validation"
sidebarTitle: "Authorization"
---
diff --git a/api-management/authentication/jwt-claim-validation.mdx b/api-management/authentication/jwt-claim-validation.mdx
index 01b72cd22..ecf7001d7 100644
--- a/api-management/authentication/jwt-claim-validation.mdx
+++ b/api-management/authentication/jwt-claim-validation.mdx
@@ -1,6 +1,6 @@
---
title: "JWT Claim Validation"
-description: "How to validate JWT claims in Tyk API Gateway."
+description: "Tyk Gateway's JWT Claim Validation enables fine-grained access control by validating registered and custom claims in JSON Web Tokens."
keywords: "Authentication, JWT, JSON Web Tokens, Claims, Validation"
sidebarTitle: "Claim Validation"
---
@@ -796,4 +796,18 @@ x-tyk-api-gateway:
nonBlocking: true
```
-The `nonBlocking` flag in the validation rule for `user.preferences.notifications` means that if this claim is missing from the received token, the token will not fail validation, but a warning will be logged.
\ No newline at end of file
+The `nonBlocking` flag in the validation rule for `user.preferences.notifications` means that if this claim is missing from the received token, the token will not fail validation, but a warning will be logged.
+
+## FAQ
+
+
+
+
+Yes, you can configure `AllowedIssuers` to specify which iss (issuer) claim values are accepted. Tokens from other issuers will be rejected.
+
+
+
+Use the `CustomClaimValidation` configuration to validate specific claims with different validation types (Required, ExactMatch, or Contains).
+
+
+
\ No newline at end of file
diff --git a/api-management/authentication/jwt-quick-start.mdx b/api-management/authentication/jwt-quick-start.mdx
new file mode 100644
index 000000000..5afd1473a
--- /dev/null
+++ b/api-management/authentication/jwt-quick-start.mdx
@@ -0,0 +1,95 @@
+---
+title: "JWT Quick Start: Securing APIs with Auth0 or Keycloak"
+description: "Learn how to secure your Tyk OAS APIs using JWT authentication with Auth0 or Keycloak as identity providers."
+keywords: "Authentication, JWT, JSON Web Tokens, Quick Start"
+sidebarTitle: "Quick Start"
+---
+
+In this tutorial, we'll secure a Tyk OAS API using JWT authentication with either Auth0 or Keycloak as the identity provider.
+
+
+If you want to try out JWT Auth without linking up to a third-party IdP then you can skip step 1 and provide the base64 encoded public key for your JWT (in the `source` field rather than configuring `jwksURIs`) in step 3. You'll need to generate a JWT for the request, but otherwise everything stays the same.
+
+Now back to the tutorial...
+
+
+We'll start by configuring the identity provider, then set up JWT validation in Tyk, create a security policy, configure the API to use the policy, and finally test the secured API with a valid token.
+
+### Prerequisites
+
+- A Tyk installation (Cloud or Self-Managed) with Tyk Dashboard license
+- An Auth0 account or Keycloak installation
+- An existing Tyk OAS API (see [this tutorial](/api-management/gateway-config-managing-oas#using-tyk-dashboard-api-designer-to-create-an-api))
+- Postman, cURL, or another API testing tool
+
+### Step-by-Step Guide
+
+1. **Configure Your Identity Provider to obtain your JWKS URI**
+
+ The first step is to configure your Identity Provider (IdP) to issue JWTs and provide a JWKS URI that Tyk can use to validate the tokens. Below are instructions for both Auth0 and Keycloak.
+
+
+
+
+ 1. Log in to your Auth0 dashboard
+ 2. Navigate to Applications > APIs and click Create API
+ 3. Enter a name and identifier (audience) for your API
+ 4. Note your Auth0 domain (e.g. `your-tenant.auth0.com`)
+ 5. Your JWKS URI will be: `https://your-tenant.auth0.com/.well-known/jwks.json`
+
+
+
+
+
+ 1. Log in to your Keycloak admin console
+ 2. Create or select a realm (e.g. `tyk-demo`)
+ 3. Navigate to Clients and create a new client with:
+ - Client ID: `tyk-api-client`
+ - Client Protocol: `openid-connect`
+ - Access Type: `confidential`
+ 4. After saving, go to the Installation tab and select "OIDC JSON" format
+ 5. Your JWKS URI will be: `http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs`
+
+
+
+
+
+2. **Create a Security Policy**
+
+ 1. In the Tyk Dashboard, navigate to **Policies**
+ 2. Click **Add Policy**
+ 3. Configure the policy:
+ - Name: `JWT Auth Policy`
+ - APIs: Select your Tyk OAS API
+ - Access Rights: Configure appropriate paths and methods
+ - Authentication: Select JWT
+ - JWT Scope Claim Name: Enter the JWT claim that contains scopes (e.g. `scope` or `permissions`)
+ - Required Scopes: Add any required scopes for access (optional)
+ 4. Click Create to save your policy
+
+3. **Configure JWT Authentication in Tyk OAS API**
+
+ 1. Navigate to APIs and select your API
+ 2. Click **Edit**
+ 3. Enable **Authentication** in the **Server** section, select **JSON Web Token (JWT)** as the authentication method
+ 4. Configure the JWT settings:
+ - Token Signing Method: Select `RSA Public Key`
+ - Subject identity claim: Set to `sub`
+ - JWKS Endpoint: Enter your JWKS URI for your IdP obtained in step 1
+ - Policy claim: Set to `pol`
+ - Default policy: Select `JWT Auth Policy` (the policy you created previously)
+ - Clock Skew (optional): Set to accommodate time differences (e.g. `10`)
+ - Authentication Token Location: `header`
+ - Header Name: `Authorization`
+ - Strip Authorization Data: `Enabled`
+ 5. Click **Save API**
+
+4. **Test your API**
+
+ 1. Obtain a JWT from your IdP
+ 2. Make a request to your API providing the JWT as a Bearer token in the `Authorization` header; Tyk will validate the JWT using the JWKS that it retrieves from your JWKS URI
+ 3. Observe that the request is successful
+
+ ```bash
+ curl -X GET {API URL} -H "Accept: application/json" -H "Authorization: Bearer {token}"
+ ```
\ No newline at end of file
diff --git a/api-management/authentication/jwt-signature-validation.mdx b/api-management/authentication/jwt-signature-validation.mdx
new file mode 100644
index 000000000..e344cbf32
--- /dev/null
+++ b/api-management/authentication/jwt-signature-validation.mdx
@@ -0,0 +1,278 @@
+---
+title: JWT Signature Validation
+description: How to validate JWT signatures in Tyk API Gateway.
+keywords: ["Authentication", "JWT", "JSON Web Tokens", "Signature", "Validation"]
+sidebarTitle: "Signature Validation"
+---
+
+## Availability
+
+| Component | Editions |
+| ----------- | ------------------------ |
+| Tyk Gateway | Community and Enterprise |
+
+## Introduction
+
+A JSON Web Token consists of three parts separated by dots: `header.payload.signature`. The signature verifies that the sender of the JWT is who it claims to be and that the message wasn't altered along the way.
+
+Tyk can validate the signature of incoming JWTs to ensure that they meet your security requirements before granting access to your APIs.
+
+## JWT Signature Fundamentals
+
+The JWT signature serves three main purposes:
+
+1. **Integrity:**
+ If anyone modifies the header or payload, the signature will no longer match.
+
+2. **Authenticity:**
+ Confirms that the token was issued by a trusted source.
+
+3. **Security:**
+ Prevents malicious users from forging tokens or altering claims.
+
+### How JWT Signatures are Created
+
+The JWT signature is created by taking the encoded header, the encoded payload, a secret, and the algorithm specified in the header.
+
+**Example**:
+
+```
+HMACSHA256(
+ base64UrlEncode(header) + "." + base64UrlEncode(payload),
+ secret
+)
+```
+
+Or, for asymmetric algorithms like RSA or ECDSA:
+
+```
+RSASHA256(
+ base64UrlEncode(header) + "." + base64UrlEncode(payload),
+ private_key
+)
+```
+
+### Verification Process
+
+When Tyk receives a JWT, it performs the following steps to validate the signature:
+
+1. It extracts the header and payload.
+2. Recomputes the signature using its own secret/private key.
+3. Compares it with the token’s signature.
+ * If they match, the token is valid.
+ * If not, the token is rejected.
+
+## Supported Algorithms for Signature Validation
+
+| Method | Cryptographic Style | Secret Type | Supported Locations for Secret | Supported Algorithms |
+| --------- | ------------------- | ------------- | ------------------------------ | ---------------------------------------------------- |
+| **HMAC** | Symmetric | Shared secret | API definition | `HS256`, `HS384`, `HS512` |
+| **RSA** | Asymmetric | Public key | API definition, JWKS endpoint | `RS256`, `RS384`, `RS512`, `PS256`, `PS384`, `PS512` |
+| **ECDSA** | Asymmetric | Public key | API definition, JWKS endpoint | `ES256`, `ES384`, `ES512` |
+
+## Configuration Options
+
+You can configure JWT signature validation using the Dashboard UI or the Tyk API definition. To configure it, you must provide Tyk with the secret or key to validate incoming JWTs.
+
+Tyk supports three methods for referencing keys and secrets:
+
+1. **Locally Stored Keys**: The key or secret is stored directly in the API definition.
+2. **External Key Value Store**: The key or secret is stored in an external key value store (e.g., Consul, Vault) and referenced in the API definition.
+3. **Remotely Stored Keys**: Tyk retrieves the key from a public JSON Web Key Set (JWKS) endpoint.
+
+Depending on the cryptographic style used, the options vary:
+
+| Cryptographic Style | Locally Stored Keys | External Key Value Store | Remotely Stored Keys (JWKS) |
+| ------------------- | ------------------- | ------------------------ | --------------------------- |
+| **Symmetric** | Yes | Yes | No |
+| **Asymmetric** | Yes | Yes | Yes |
+
+
+### Locally Stored Keys and Secrets
+
+When storing the key or secret in the API definition, it is first base64 encoded and then configured in `server.authentication.securitySchemes..source` (in Tyk Classic, this is [jwt_source](/api-management/gateway-config-tyk-classic#configuring-authentication-for-tyk-classic-apis).
+
+For example, the Tyk OAS fragment below configures the secret `mysecret` to validate the signatures of incoming JWTs. **Note** that the secret has been base64 encoded and then stored in `source`:
+
+```yaml
+x-tyk-api-gateway:
+ server:
+ authentication:
+ securitySchemes:
+ jwtAuth:
+ source: bXlzZWNyZXQ=
+```
+
+Refer to the [Tyk OAS API Definition](/api-management/gateway-config-tyk-oas#jwt) reference for details.
+
+### External Key Value Store
+
+For improved separation of concerns and flexibility, the key/secret can be placed in an [external key value store](/tyk-configuration-reference/kv-store), with the appropriate reference configured in the API definition.
+
+For example, this fragment configures the JWT authentication middleware to use the secret at `consul://secrets/jwt-secret` to validate the signatures of incoming JWTs. Note that the external KV store reference has been base64 encoded and then stored in `source`:
+
+```yaml
+x-tyk-api-gateway:
+ server:
+ authentication:
+ securitySchemes:
+ jwtAuth:
+ source: Y29uc3VsOi8vc2VjcmV0cy9qd3Qtc2VjcmV0
+```
+
+### Remotely Stored Keys (JWKS endpoint)
+
+Tyk can retrieve public keys from JSON Web Key Sets (JWKS) endpoints to validate the signature of incoming JWTs. Tyk supports configuring [single](#single-jwks-endpoint) or [multiple](#multiple-jwks-endpoints) JWKS endpoints with [caching](#jwks-caching) capabilities.
+
+#### Feature Compatibility Summary
+
+| Feature | Tyk Classic APIs | Tyk OAS APIs | Available From |
+| ------------------------------ | ---------------- | ------------ | -------------- |
+| Single JWKS Endpoint Support | ✅ | ✅ | All versions |
+| Multiple JWKS Endpoint Support | ❌ | ✅ | 5.9.0 |
+
+#### Single JWKS endpoint
+
+Before Tyk 5.9.0 and when using Tyk Classic APIs, Tyk can only retrieve a single JSON Web Key Set from a JWKS endpoint configured in `server.authentication.securitySchemes..source` (in Tyk Classic, this is [jwt_source](/api-management/gateway-config-tyk-classic#configuring-authentication-for-tyk-classic-apis)). This field accepts the base64-encoded full URI (including the protocol) of the JWKS endpoint.
+
+For example, the following Tyk OAS fragment configures the JWT authentication middleware to retrieve the JWKS from `https://your-tenant.auth0.com/.well-known/jwks.json` when validating the signatures of incoming JWTs. Note that the JWKS endpoint has been base64 encoded and then stored in `source`:
+
+```yaml
+x-tyk-api-gateway:
+ server:
+ authentication:
+ securitySchemes:
+ jwtAuth:
+ source: aHR0cHM6Ly95b3VyLXRlbmFudC5hdXRoMC5jb20vLndlbGwta25vd24vandrcy5qc29u
+```
+
+#### Multiple JWKS endpoints
+
+From **Tyk 5.9.0** onwards, Tyk OAS APIs can validate against multiple JWKS endpoints, allowing you to use different IdPs to issue JWTs for the same API.
+
+Multiple JWKS endpoints can be configured in the `.jwksURIs` array. Tyk will retrieve the JSON Web Key Sets from each of these endpoints, which will be used to attempt to validate the received JWT.
+
+
+**Note**
+
+- The `.jwksURIs` URIs are not base64 encoded in the API definition and so are human-readable.
+- If both `.source` and `.jwksURIs` are configured, the latter will take precedence.
+- Multiple JWKS endpoints and the `jwksURIs` array are not supported by Tyk Classic APIs.
+
+
+For example, the following fragment will configure the JWT authentication middleware to retrieve the JWKS from both Auth0 and Keycloak when validating the signature of incoming JWTs:
+
+```yaml
+x-tyk-api-gateway:
+ server:
+ authentication:
+ securitySchemes:
+ jwtAuth:
+ jwksURIs:
+ - url: https://your-tenant.auth0.com/.well-known/jwks.json
+ - url: http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs
+```
+
+## JWKS caching
+
+Tyk caches the [JSON Web Key Set](https://datatracker.ietf.org/doc/html/rfc7517) (JWKS) retrieved from JWKS endpoints to reduce the performance impact of contacting external services during request handling. A separate cache is maintained for each JWKS endpoint and API, with a default validity period of *240 seconds*, after which the cache is refreshed when a new request is received.
+
+For example, the following fragment will configure the JWT authentication middleware to retrieve the JWKS from both Auth0 and Keycloak when validating the signature of incoming JWTs, assigning a 300 second validity period to the Auth0 JWKS and 180 second validity period for Keycloak:
+
+```yaml
+x-tyk-api-gateway:
+ server:
+ authentication:
+ securitySchemes:
+ jwtAuth:
+ jwksURIs:
+ - url: https://your-tenant.auth0.com/.well-known/jwks.json
+ cacheTimeout: "300s" # 5 minutes
+ - url: http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs
+ cacheTimeout: "3m" # 3 minutes (alternative format)
+```
+
+### Feature Compatibility Summary
+
+From **Tyk 5.10.0** onwards, we have introduced enhanced JWKS caching for [Tyk OAS APIs](/api-management/gateway-config-tyk-oas) with the following improvements:
+
+- **Configurable cache timeout** - Set custom validity periods per JWKS endpoint
+- **Pre-fetch functionality** - Automatically retrieve and cache all JWKS when the API loads to the Gateway, ensuring the first request doesn't experience the latency of fetching keys from external endpoints
+- **Cache management API** - New endpoints to manually invalidate JWKS caches
+
+The table below summarizes the availability of JWKS caching features between Tyk Classic and Tyk OAS APIs:
+
+
+| Feature | Tyk Classic | Tyk OAS | Available From |
+| -------------------------- | ----------- | ------- | -------------- |
+| Single JWKS endpoint | ✅ | ✅ | All versions |
+| Multiple JWKS endpoints | ❌ | ✅ | Tyk 5.9.0+ |
+| Configurable cache timeout | ❌ | ✅ | Tyk 5.10.0+ |
+| Pre-fetch functionality | ❌ | ✅ | Tyk 5.10.0+ |
+| Cache management API | ✅ | ✅ | Tyk 5.10.0+ |
+
+### Configuration Options
+
+| Field | Type | Description | Default | Supported Formats |
+| -------------- | ------ | --------------------- | -------- | ------------------------------ |
+| `url` | string | JWKS endpoint URL | Required | Full URI including protocol |
+| `cacheTimeout` | string | Cache validity period | 240s | `"300s"`, `"5m"`, `"1h"`, etc. |
+
+For more details, refer to the [Tyk OAS API definition reference](/api-management/gateway-config-tyk-oas#jwk).
+
+
+**Note**
+
+Tyk Classic APIs continue to use the existing JWKS caching behavior with the 240-second default timeout. The enhanced caching features are available only for Tyk OAS APIs.
+
+
+### JWKS Cache Management
+
+New [Gateway API](/tyk-gateway-api) endpoints are available from **Tyk 5.10.0** to manage JWKS caches programmatically. These endpoints work for both Tyk OAS and Tyk Classic APIs:
+
+| Endpoint | Method | Description |
+| ------------------------- | -------- | ---------------------------------------- |
+| `/tyk/cache/jwks` | `DELETE` | Invalidate JWKS caches for all APIs |
+| `/tyk/cache/jwks/{apiID}` | `DELETE` | Invalidate JWKS cache for a specific API |
+
+**Note:** These endpoints are currently available only through the Tyk [Gateway API](/tyk-gateway-api) and are not yet extended to the Tyk [Dashboard API](/tyk-dashboard-api).
+
+**Example usage:**
+```bash
+# Flush all JWKS caches
+curl -X DELETE http://your-gateway:8080/tyk/cache/jwks \
+ -H "x-tyk-authorization: your-secret"
+
+# Flush JWKS cache for specific API
+curl -X DELETE http://your-gateway:8080/tyk/cache/jwks/your-api-id \
+ -H "x-tyk-authorization: your-secret"
+```
+
+## FAQ
+
+
+
+Yes, each API definition can have its own JWT configuration with different signing methods and keys.
+
+
+
+You can use JWKS (JSON Web Key Sets) by configuring `JWTJwksURIs` with the URLs of your JWKS endpoints. Tyk will automatically fetch and use the appropriate key based on the kid (Key ID) in the token header.
+
+
+
+Tyk caches JWKS responses. You can configure the cache timeout using the CacheTimeout parameter in the `JWTJwksURIs` configuration. This ensures that temporary JWKS endpoint outages don't affect API availability.
+
+
+
+No, JWKS endpoints are designed for asymmetric cryptography (RSA and ECDSA), where public keys are used for signature verification. Symmetric cryptography (HMAC) requires a shared secret, which cannot be retrieved from a JWKS endpoint.
+
+
+
+By default, Tyk refreshes the JWKS cache every 240 seconds. However, you can customize the cache timeout for each JWKS endpoint in Tyk OAS APIs using the `cacheTimeout` field in the API definition.
+
+
+
+The JWKS (JSON Web Key Set) pre-fetching functionality in Tyk Gateway is automatic and not configurable in terms of enabling/disabling it. When you configure JWKS URLs in your API definition, Tyk will automatically pre-fetch the keys when the API loads.
+
+
+
\ No newline at end of file
diff --git a/api-management/authentication/jwt-split-token.mdx b/api-management/authentication/jwt-split-token.mdx
new file mode 100644
index 000000000..020819631
--- /dev/null
+++ b/api-management/authentication/jwt-split-token.mdx
@@ -0,0 +1,210 @@
+---
+title: JWT Split Token
+description: Learn how to implement JWT Split Token flow in Tyk to enhance security by separating JWT components and storing sensitive data server-side.
+keywords: ["Authentication", "JWT", "JSON Web Tokens", "Split Token", "Security"]
+sidebarTitle: "Split Token"
+---
+
+## Availability
+
+| Component | Editions |
+| :------------- | :------------------------- |
+| Tyk Gateway | Community and Enterprise |
+
+## Introduction
+
+Split Token Flow addresses a fundamental security concern with JWT tokens: when a JWT is stored on a client device (browser, mobile app, etc.), all of its contents can be easily decoded since JWTs are only base64-encoded, not encrypted. This means sensitive information in the payload is potentially exposed.
+
+The JWT consists of three parts:
+
+
+
+In the above example you can see that they are:
+
+- Header: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9`
+- Payload: `eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJlbWFpbCI6ImhlbGxvQHdvcmxkLmNvbSJ9`
+- Signature: `EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0`
+
+The Split Token approach provides a solution by:
+
+1. Separating the JWT into its three component parts: header, payload, and signature
+2. Storing only the signature on the client side (which by itself is meaningless)
+3. Keeping the header and payload securely on the server side (in Tyk)
+4. Reconstructing the complete JWT when needed for authentication
+
+This approach combines the benefits of JWTs (rich claims, stateless validation) with the security of opaque tokens (no information disclosure).
+
+### When to Use Split Token Flow
+
+Consider using Split Token Flow when:
+
+- Your JWT payload contains sensitive information that shouldn't be exposed to clients
+- You want to prevent token inspection by malicious actors
+- You need the flexibility of JWT while maintaining higher security
+- You're implementing systems that must meet strict security compliance requirements
+
+## How Split Token Flow Works
+
+Here's how the process works with Tyk Gateway:
+
+```mermaid
+sequenceDiagram
+ participant Client
+ participant Tyk as Tyk Gateway
+ participant Redis as Tyk Redis
+ participant Auth as Authorization Server
+
+ %% Token Issuance Flow
+ rect rgb(240, 240, 255)
+ note over Client, Auth: Token Issuance
+ Client->>Tyk: Request token from /token endpoint
+ Tyk->>Auth: Forward request to Auth Server
+ Auth->>Tyk: Return complete JWT (header.payload.signature)
+ Tyk->>Tyk: Split JWT into components
+ Tyk->>Redis: Store header & payload using signature as key
+ Tyk->>Client: Return only signature as "opaque" token
+ end
+
+ %% Token Usage Flow
+ rect rgb(245, 255, 245)
+ note over Client, Auth: Token Usage
+ Client->>Tyk: API request with signature as Bearer token
+ Tyk->>Redis: Look up header & payload using signature
+ Redis->>Tyk: Return stored header & payload
+ Tyk->>Tyk: Reconstruct complete JWT
+ Tyk->>Tyk: Validate JWT
+ Tyk->>Auth: Forward request with complete JWT
+ Auth->>Tyk: Response
+ Tyk->>Client: Return response to client
+ end
+```
+
+1. **Token Issuance**:
+
+ - A `/token` endpoint is configured on Tyk from which the client should request the access token
+ - Tyk requests an access token from an authorization server (e.g., Keycloak) on behalf of the client
+ - The authorization server returns a complete JWT
+ - Tyk intercepts this response through a [Virtual Endpoint](/api-management/traffic-transformation/virtual-endpoints)
+ - Tyk splits the JWT into its components and stores the header and payload in its Redis database
+ - Only the signature portion is returned to the client as an "opaque" token
+
+2. **Token Usage**:
+
+ - The client makes API requests using only the signature as their access token
+ - Tyk receives the request and looks up the stored header and payload using the signature
+ - Tyk reconstructs the complete JWT and validates it
+ - If valid, Tyk forwards the request to the upstream API with the full JWT
+
+3. **Security Benefits**:
+
+ - The client never possesses the complete JWT, only a meaningless signature
+ - Token contents cannot be inspected by client-side code or malicious actors
+ - Token validation still occurs using standard JWT verification
+
+
+## Implementing Split Token Flow
+
+1. **Create a Virtual Endpoint for Token Issuance**
+
+ First, create a virtual endpoint in Tyk that will:
+
+ - Receive authentication requests from clients
+ - Forward these requests to your authorization server
+ - Split the returned JWT
+ - Store the header and payload in Tyk's storage
+ - Return only the signature to the client
+ - Here's a simplified implementation:
+
+ ```javascript
+ function splitTokenHandler(request, session, config) {
+ // 1. Forward the client's credentials to the authorization server
+ var authServerResponse = forwardToAuthServer(request);
+
+ if (authServerResponse.Code !== 200) {
+ return TykJsResponse({
+ Body: authServerResponse.Body,
+ Code: authServerResponse.Code
+ }, session.meta_data);
+ }
+
+ // 2. Extract the JWT from the response
+ var responseBody = JSON.parse(authServerResponse.Body);
+ var fullJWT = responseBody.access_token;
+
+ // 3. Split the JWT into its components
+ var jwtParts = fullJWT.split(".");
+ var header = jwtParts[0];
+ var payload = jwtParts[1];
+ var signature = jwtParts[2];
+
+ // 4. Store the complete JWT in Tyk's Redis database using the signature as the key
+ // This function would use Tyk's storage API to save the data
+ storeJWTComponents(signature, header, payload, fullJWT);
+
+ // 5. Modify the response to return only the signature
+ responseBody.access_token = signature;
+
+ return TykJsResponse({
+ Body: JSON.stringify(responseBody),
+ Code: 200
+ }, session.meta_data);
+ }
+ ```
+
+ Note that this example includes some level of abstraction for clarity and so is not a full implementation.
+
+2. **Configure Custom Pre-Auth Plugin**
+
+ Next, create a custom pre-auth plugin that reconstructs the JWT before it reaches the standard Tyk JWT Auth middleware:
+
+ ```javascript
+ function reconstructJWT(request, session, config) {
+ // 1. Extract the signature from the Authorization header
+ var authHeader = request.Headers["Authorization"];
+ var signature = authHeader.replace("Bearer ", "");
+
+ // 2. Retrieve the stored JWT components using the signature
+ var storedJWT = retrieveJWTComponents(signature);
+
+ if (!storedJWT) {
+ return TykJsResponse({
+ Body: "Invalid token",
+ Code: 401
+ }, session.meta_data);
+ }
+
+ // 3. Replace the Authorization header with the full JWT
+ request.SetHeaders["Authorization"] = "Bearer " + storedJWT.fullJWT;
+
+ return request;
+ }
+ ```
+
+3. **Test the Implementation**
+
+ To test your Split Token Flow:
+
+ Request a token from your Tyk virtual endpoint:
+
+ ```bash
+ curl -X POST https://your-tyk-gateway/token \
+ -d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"
+ ```
+
+ You'll receive a response with only the signature as the access token, for example:
+
+ ```json
+ {
+ "access_token": "EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0",
+ "token_type": "bearer",
+ "expires_in": 3600
+ }
+ ```
+
+ Use this token to access your JWT Auth protected API where you have configured the custom pre-auth plugin and JWT Auth:
+
+ ```bash
+ curl https://your-tyk-gateway/protected-api \
+ -H "Authorization: Bearer EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0"
+ ```
+
diff --git a/basic-config-and-security/security/authentication-authorization/json-web-tokens.mdx b/basic-config-and-security/security/authentication-authorization/json-web-tokens.mdx
index 9d081e8ea..da66397d4 100644
--- a/basic-config-and-security/security/authentication-authorization/json-web-tokens.mdx
+++ b/basic-config-and-security/security/authentication-authorization/json-web-tokens.mdx
@@ -7,184 +7,88 @@ sidebarTitle: "Overview"
## Introduction
-JSON Web Token (JWT) is an open standard ([RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519)) that defines a compact and self-contained way for securely transmitting claims between parties as a JSON object. The information in the JSON object is digitally signed using either a secret (with the HMAC algorithm) or a public/private key pair (using RSA or ECDSA encryption) allowing the JWT to be used for client authentication.
+JSON Web Token (JWT) is an open standard ([RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519)) that defines a compact and self-contained way for securely transmitting claims between parties as a JSON object.
-### JWT Workflow
-
-JWTs are commonly used in OAuth 2.0 and OpenID Connect flows to authenticate users and authorize access to APIs. The following diagram illustrates the typical flow of JWT authentication with Tyk Gateway:
-
-```mermaid
-sequenceDiagram
- participant User
- participant IdP as Identity Provider (IdP)
- participant Client as Client Application
- participant Tyk as Tyk Gateway
-
- User->>IdP: Authorizes Client
- IdP-->>Client: Issues JWT (with claims)
- Client->>Tyk: Sends API request with JWT
- Tyk->>IdP: (Optional) Fetch JWKS for validation
- Tyk-->>Tyk: Validates JWT Signature
- Tyk-->>Tyk: Extracts Claims
- Tyk-->>Tyk: Applies Security Policies based on Claims
- Tyk-->>Client: Forwards request or responds
-```
-
-1. **Token Issuance by Identity Provider (IdP):**
- The Identity Provider (IdP) issues a JWT with the appropriate claims. These claims represent the permissions granted by the user to the client application.
-
-2. **Client as Token Bearer:**
- The Client Application acts as the *bearer* of the JWT (access token). Although the client may have access to multiple APIs, the user's delegated scopes restrict actual access. For example, a client with access to 5 APIs might only get a token allowing access to 2, depending on the user's delegation.
-
-3. **JWT Presented to Tyk Gateway:**
- The client includes the JWT in its API requests to the Tyk Gateway as an access token.
-
-4. **JWT Validation via JWK/JWKS:**
- Tyk validates the JWT's signature using a JSON Web Key (JWK). This key can be statically configured or dynamically fetched from the IdP via a JSON Web Key Set (JWKS) endpoint, supporting key rotation and multiple keys.
-
-5. **Authorization via Claims and Policies:**
- Claims within the JWT can be used by Tyk Gateway's authorization process to configure rate and quota limits via Tyk's [Security Policy](/api-management/policies) system. Within the API definition, JWT claims can be "mapped" onto security policies which will then be applied to the request.
-
-6. **Stateless Authentication:**
- A key advantage of JWT authentication is that Tyk does not store any user credentials or session data. It never sees the user directly - it trusts the authorization server to have authenticated the user and issued a valid token.
+The information in the JSON object is digitally signed using either a secret (with the HMAC algorithm) or a public/private key pair (using RSA or ECDSA encryption) allowing the JWT to be used for client authentication.
### Key Benefits
-This documentation is focused on how to use Tyk's JWT Auth and there are many excellent sources online where you can learn more about JWTs so we won't deep-dive into that topic, but to whet your appetite, here are some of the benefits from using JWT with Tyk:
-
- **Stateless Authentication**: Eliminates the need for server-side session storage, improving scalability.
- **Flexible Integration**: Works with multiple identity providers including Auth0, Okta, and custom JWT issuers.
- **Enhanced Security**: Supports multiple signature validation methods (RSA, ECDSA, HMAC) and claim verification.
- **Granular Access Control**: Leverage JWT claims for policy enforcement and scope-based permissions.
- **Performance Optimized**: Efficient token validation with minimal overhead and support for JWKS caching.
-## Quick Start: Securing APIs with Auth0 or Keycloak
-
-In this tutorial, we'll secure a Tyk OAS API using JWT authentication with either Auth0 or Keycloak as the identity provider.
-
-
-
-If you want to try out JWT Auth without linking up to a third-party IdP then you can skip step 1 and provide the base64 encoded public key for your JWT (in the `source` field rather than configuring `jwksURIs`) in step 3. You'll need to generate a JWT for the request, but otherwise everything stays the same.
-
-Now back to the tutorial...
-
-
-
-We'll start by configuring the identity provider, then set up JWT validation in Tyk, create a security policy, configure the API to use the policy, and finally test the secured API with a valid token.
-
-### Prerequisites
-
-- A Tyk installation (Cloud or Self-Managed) with Tyk Dashboard license
-- An Auth0 account or Keycloak installation
-- An existing Tyk OAS API (see [this tutorial](/api-management/gateway-config-managing-oas#using-tyk-dashboard-api-designer-to-create-an-api))
-- Postman, cURL, or another API testing tool
-
-### Step-by-Step Guide
-
-1. **Configure Your Identity Provider to obtain your JWKS URI**
-
- The first step is to configure your Identity Provider (IdP) to issue JWTs and provide a JWKS URI that Tyk can use to validate the tokens. Below are instructions for both Auth0 and Keycloak.
-
-
-
-
- 1. Log in to your Auth0 dashboard
- 2. Navigate to Applications > APIs and click Create API
- 3. Enter a name and identifier (audience) for your API
- 4. Note your Auth0 domain (e.g. `your-tenant.auth0.com`)
- 5. Your JWKS URI will be: `https://your-tenant.auth0.com/.well-known/jwks.json`
+## How JWT Authentication works with Tyk
-
+JWTs are commonly used in OAuth 2.0 and OpenID Connect flows to authenticate users and authorize access to APIs. The following diagram and steps outline the flow when using JWT Auth to secure access to your API through Tyk.
-
+
- 1. Log in to your Keycloak admin console
- 2. Create or select a realm (e.g. `tyk-demo`)
- 3. Navigate to Clients and create a new client with:
- - Client ID: `tyk-api-client`
- - Client Protocol: `openid-connect`
- - Access Type: `confidential`
- 4. After saving, go to the Installation tab and select "OIDC JSON" format
- 5. Your JWKS URI will be: `http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs`
+1. **Authentication and Token Issuance**
-
+ Alice (the *user* or *resource owner*) authenticates with an Identity Provider (IdP) via the client application (steps 1 and 2).
+ - The IdP issues a JWT containing specific **claims** (permissions delegated by the user).
+ - The client application receives this authorization code and exchanges it for an access token (step 3).
+ - The client acts as the **Token Bearer**, holding the token to access protected resources on Alice's behalf.
-
+2. **Request to Gateway**
+
+ When the client sends a request to the API gateway, it includes the access token (JWT) in the request, usually in the `Authorization` header as a Bearer token (step 4).
-2. **Create a Security Policy**
+3. **Token Validation**
- 1. In the Tyk Dashboard, navigate to **Policies**
- 2. Click **Add Policy**
- 3. Configure the policy:
- - Name: `JWT Auth Policy`
- - APIs: Select your Tyk OAS API
- - Access Rights: Configure appropriate paths and methods
- - Authentication: Select JWT
- - JWT Scope Claim Name: Enter the JWT claim that contains scopes (e.g. `scope` or `permissions`)
- - Required Scopes: Add any required scopes for access (optional)
- 4. Click Create to save your policy
+ Tyk validates the token's signature using the shared secret or public key(s) of the trusted issuer (IdP). This process typically involves:
+ - Locating the JWT in the request (header, cookie, or query parameter).
+ - Decoding the JWT header to extract the `kid` (Key ID).
+ - Fetching public keys from configured JWKS URIs (or using a local static key).
+ - Searching the retrieved keys for a match to the `kid`.
+ - Validating the signature using the matching JWK.
+ - Ensuring the token is valid and not expired.
+ - *If any validation step fails, the request is rejected immediately.*
-3. **Configure JWT Authentication in Tyk OAS API**
+ To know more about how Tyk validates JWT signatures and claims, see [JWT Signature Validation](/api-management/authentication/jwt-signature-validation) and [JWT Claim Validation](/api-management/authentication/jwt-claim-validation).
- 1. Navigate to APIs and select your API
- 2. Click **Edit**
- 3. Enable **Authentication** in the **Server** section, select **JSON Web Token (JWT)** as the authentication method
- 4. Configure the JWT settings:
- - Token Signing Method: Select `RSA Public Key`
- - Subject identity claim: Set to `sub`
- - JWKS Endpoint: Enter your JWKS URI for your IdP obtained in step 1
- - Policy claim: Set to `pol`
- - Default policy: Select `JWT Auth Policy` (the policy you created previously)
- - Clock Skew (optional): Set to accommodate time differences (e.g. `10`)
- - Authentication Token Location: `header`
- - Header Name: `Authorization`
- - Strip Authorization Data: `Enabled`
- 5. Click **Save API**
+4. **Internal Identity Creation**
-4. **Test your API**
+ Once validated, Tyk creates an internal session for the request (step 5). This session is used to control access rights, consumption limits, and analytics. Tyk does not store user credentials; instead, it links the session to Alice using an identity [extracted from the JWT claims](/api-management/authentication/jwt-authorization#identifying-the-session-owner).
- 1. Obtain a JWT from your IdP
- 2. Make a request to your API providing the JWT as a Bearer token in the `Authorization` header; Tyk will validate the JWT using the JWKS that it retrieves from your JWKS URI
- 3. Observe that the request is successful
+ To know more about how Tyk authorizes requests using JWT claims, see [JWT Authorization](/api-management/authentication/jwt-authorization).
- ```bash
- curl -X GET {API URL} -H "Accept: application/json" -H "Authorization: Bearer {token}"
- ```
+5. **Policy Enforcement**
-## How JWT Authentication works with Tyk
+ Tyk enforces authorization by inspecting specific claims to determine which Security Policies apply (step 6):
+ - Tyk checks the **Policy Claim** (identified by the value stored in `basePolicyClaims`).
+ - It maps this claim to a configured Tyk Security Policy. If no direct map exists, a `defaultPolicy` may be applied.
+ - The applied policy configures the specific Access Rights (ACLs), rate limits, and usage quotas for that specific session.
-This diagram outlines the flow when using JWT Auth to secure access to your API.
+ To know more about how Tyk identifies the policies to be applied, see [Identifying the Tyk Policies to be Applied](/api-management/authentication/jwt-authorization#identifying-the-tyk-policies-to-be-applied).
-
+6. **Proxy to Upstream**
-1. Alice (the *user* or *resource owner*) authenticates with the Identity Provider (IdP) and consents to delegate specific permissions to a client application (steps 1 and 2).
+ If the token is valid and the policy allows the request, Tyk proxies the traffic to your upstream target service (step 7).
-2. The client application receives an authorization code, which it then exchanges for an access token (step 3). This is a bearer token, meaning that the client can present it to access protected resources on behalf of the user (resource owner / Alice).
-3. When the client sends a request to the API gateway , it includes the access token (JWT) in the request - usually in the Authorization header as a Bearer token (step 4).
-
-4. Tyk validates the token's signature, using the public key(s) of the trusted issuer (IdP):
- - locate the JWT in the request (header, cookie or query parameter)
- - decode the JWT
- - extract the `kid` (Key ID) from the token header
- - fetch the public keys from all configured JWKS URIs (or use locally declared static public key)
- - merge all the retrieved public keys into a single list
- - search this list for a public key matching the extracted `kid`
- - if no match is found, the validation fails, and the request is rejected
- - if a matching key is found, the JWT signature is validated using the parameters in the JWK
- - if signature validation fails, the request is rejected
- - if the token is valid and not expired, the request is authenticated as coming from the client, and is accepted
-
-5. Next, Tyk will create an internal session for the request which will be used to control access rights, consumption limits and to identify the request in tracking logs (step 5). The session is linked to Alice using an identity that is [extracted from the JWT claims](/api-management/authentication/jwt-authorization#identifying-the-session-owner).
+### JWT Workflow
-6. In step 6 Tyk will proceed to enforce authorization by checking other claims to determine which Security Policies should be applied to the session:
- - check for the value in the policy claim within the JWT (identified by the value stored in `basePolicyClaims`)
- - use this to identify the Tyk Security Policy (or policies) to be applied to the request
- - if there is no direct policy mapping, then the `defaultPolicy` will be used
- - apply the identified policies to the session, configuring access rights, rate limits and usage quota
+```mermaid
+sequenceDiagram
+ participant User
+ participant IdP as Identity Provider (IdP)
+ participant Client as Client Application
+ participant Tyk as Tyk Gateway
+ User->>IdP: Authorizes Client
+ IdP-->>Client: Issues JWT (with claims)
+ Client->>Tyk: Sends API request with JWT
+ Tyk->>IdP: (Optional) Fetch JWKS for validation
+ Tyk-->>Tyk: Validates JWT Signature
+ Tyk-->>Tyk: Extracts Claims
+ Tyk-->>Tyk: Applies Security Policies based on Claims
+ Tyk-->>Client: Forwards request or responds
+```
-## Configuring your API to use JWT authentication
+## Configuration Options
The OpenAPI Specification treats JWT authentication as a variant of [bearer authentication](https://swagger.io/docs/specification/v3_0/authentication/bearer-authentication/) in the `components.securitySchemes` object using the `type: http`, `scheme: bearer` and `bearerFormat: jwt`:
@@ -249,312 +153,3 @@ x-tyk-api-gateway:
### Using Tyk Classic APIs
As noted in the Tyk Classic API [documentation](/api-management/gateway-config-tyk-classic#configuring-authentication-for-tyk-classic-apis), you can select JSON Web Token authentication using the `use_jwt` option. Tyk Classic APIs do not natively support multiple JWKS endpoints, though a [custom authentication plugin](/api-management/plugins/plugin-types#authentication-plugins) could be used to implement this functionality.
-
-## Signature Validation
-
-| Method | Cryptographic Style | Secret Type | Supported Locations for Secret | Supported Algorithms |
-| :--------- | :------------------- | :------------- | :------------------------------ | :---------------------------------------------------- |
-| **HMAC** | Symmetric | Shared secret | API definition | `HS256`, `HS384`, `HS512` |
-| **RSA** | Asymmetric | Public key | API definition, JWKS endpoint | `RS256`, `RS384`, `RS512`, `PS256`, `PS384`, `PS512` |
-| **ECDSA** | Asymmetric | Public key | API definition, JWKS endpoint | `ES256`, `ES384`, `ES512` |
-
-### Secret Management
-
-You must provide Tyk with the secret or key to be used to validate the incoming JWTs.
-
-- For the asymmetric methods (RSA and ECDSA) the public key can be stored in the API definition or Tyk can retrieve from a public JSON Web Key Sets (JWKS) endpoint (supporting dynamic rotation of keys in the JWKS)
-- For symmetric encryption (HMAC), the secret is shared between the client and Tyk and so is stored within the API definition not on the public JWKS server
-
-#### Locally Stored Keys and Secrets
-
-When storing the key or secret in the API definition, it is first base64 encoded and then configured in `server.authentication.securitySchemes..source` (in Tyk Classic, this is `jwt_source`). For improved separation of concerns and flexibility, the key/secret can be placed in an [external key value store](/tyk-configuration-reference/kv-store), with the appropriate reference configured in the API definition.
-
-For example, this fragment will configure the JWT authentication middleware to use the secret located at `consul://secrets/jwt-secret` to validate the signature of incoming JWTs. Note that the external KV store reference has been base64 encoded and then stored in `source`:
-
-```yaml
-x-tyk-api-gateway:
- server:
- authentication:
- securitySchemes:
- jwtAuth:
- source: Y29uc3VsOi8vc2VjcmV0cy9qd3Qtc2VjcmV0
-```
-
-#### Remotely Stored Keys (JWKS endpoint)
-
-##### Single JWKS endpoint
-
-Prior to Tyk 5.9.0 and when using Tyk Classic APIs, Tyk can only retrieve a single JSON Web Key Set, from a JWKS endpoint configured in `server.authentication.securitySchemes..source` (in Tyk Classic, this is `jwt_source`). This field accepts the base64 encoded full URI (including protocol) of the JWKS endpoint.
-
-For example, the following Tyk OAS fragment will configure the JWT authentication middleware to retrieve the JWKS from `https://your-tenant.auth0.com/.well-known/jwks.json` when validating the signature of incoming JWTs. Note that the JWKS endpoint has been base64 encoded and then stored in `source`:
-
-```yaml
-x-tyk-api-gateway:
- server:
- authentication:
- securitySchemes:
- jwtAuth:
- source: aHR0cHM6Ly95b3VyLXRlbmFudC5hdXRoMC5jb20vLndlbGwta25vd24vandrcy5qc29u
-```
-
-##### Multiple JWKS endpoints
-
-From **Tyk 5.9.0** onwards, Tyk OAS APIs can validate against multiple JWKS endpoints, allowing you to use different IdPs to issue JWTs for the same API. Multiple JWKS endpoints can be configured in the `.jwksURIs` array. Note that these URIs are not base64 encoded in the API definition and so are human-readable. Tyk will retrieve the JSON Web Key Sets from each of these endpoints and these will be used to attempt validation of the received JWT.
-
-For example, the following fragment will configure the JWT authentication middleware to retrieve the JWKS from both Auth0 and Keycloak when validating the signature of incoming JWTs:
-
-```yaml
-x-tyk-api-gateway:
- server:
- authentication:
- securitySchemes:
- jwtAuth:
- jwksURIs:
- - url: https://your-tenant.auth0.com/.well-known/jwks.json
- - url: http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs
-```
-
-*Multiple JWKS endpoints and the `jwksURIs` array are not supported by Tyk Classic APIs.*
-
-
-
-If both `.source` and `.jwksURIs` are configured, the latter will take precedence.
-
-
-
-#### JWKS caching
-
-Tyk caches the JSON Web Key Set (JWKS) retrieved from JWKS endpoints to reduce the performance impact of contacting external services during request handling. A separate cache is maintained for each JWKS endpoint for each API, with a default validity period of *240 seconds*, after which the cache will be refreshed when a new request is received.
-
-From **Tyk 5.10.0** onwards, we have introduced enhanced JWKS caching for Tyk OAS APIs with the following improvements:
-
-- **Configurable cache timeout** - Set custom validity periods per JWKS endpoint
-- **Pre-fetch functionality** - Automatically retrieve and cache all JWKS when the API loads to the Gateway, ensuring the first request doesn't experience the latency of fetching keys from external endpoints
-- **Cache management API** - New endpoints to manually invalidate JWKS caches
-
-For example, the following fragment will configure the JWT authentication middleware to retrieve the JWKS from both Auth0 and Keycloak when validating the signature of incoming JWTs, assigning a 300 second validity period to the Auth0 JWKS and 180 second validity period for Keycloak:
-
-```yaml
-x-tyk-api-gateway:
- server:
- authentication:
- securitySchemes:
- jwtAuth:
- jwksURIs:
- - url: https://your-tenant.auth0.com/.well-known/jwks.json
- cacheTimeout: "300s" # 5 minutes
- - url: http://your-keycloak-host/realms/tyk-demo/protocol/openid-connect/certs
- cacheTimeout: "3m" # 3 minutes (alternative format)
-```
-##### Configuration Options
-
-| Field | Type | Description | Default | Supported Formats |
-| :------- | :------ | :------------- | :--------- | :------------------- |
-| `url` | string | JWKS endpoint URL | Required | Full URI including protocol |
-| `cacheTimeout` | string | Cache validity period | 240s | `"300s"`, `"5m"`, `"1h"`, etc. |
-
-
-
-
-Tyk Classic APIs continue to use the existing JWKS caching behavior with the 240-second default timeout. The enhanced caching features are available only for Tyk OAS APIs.
-
-
-
-##### JWKS Cache Management
-
-New Gateway API endpoints are available from **Tyk 5.10.0** to manage JWKS caches programmatically. These endpoints work for both Tyk OAS and Tyk Classic APIs:
-
-| Endpoint | Method | Description |
-| :---------- | :--------- | :------------- |
-| `/tyk/cache/jwks` | `DELETE` | Invalidate JWKS caches for all APIs |
-| `/tyk/cache/jwks/{apiID}` | `DELETE` | Invalidate JWKS cache for a specific API |
-
-**Note:** These endpoints are currently available only through the Tyk Gateway API and are not yet extended to the Tyk Dashboard API.
-
-**Example usage:**
-```bash
-# Flush all JWKS caches
-curl -X DELETE http://your-gateway:8080/tyk/cache/jwks \
- -H "x-tyk-authorization: your-secret"
-
-# Flush JWKS cache for specific API
-curl -X DELETE http://your-gateway:8080/tyk/cache/jwks/your-api-id \
- -H "x-tyk-authorization: your-secret"
-```
-
-##### Feature Compatibility Summary
-
-| Feature | Tyk Classic | Tyk OAS | Available From |
-| :--------- | :------------- | :--------- | :---------------- |
-| Single JWKS endpoint | ✅ | ✅ | All versions |
-| Multiple JWKS endpoints | ❌ | ✅ | Tyk 5.9.0+ |
-| Configurable cache timeout | ❌ | ✅ | Tyk 5.10.0+ |
-| Pre-fetch functionality | ❌ | ✅ | Tyk 5.10.0+ |
-| Cache management API | ✅ | ✅ | Tyk 5.10.0+ |
-
-## Split Token Flow
-
-Split Token Flow addresses a fundamental security concern with JWT tokens: when a JWT is stored on a client device (browser, mobile app, etc.), all of its contents can be easily decoded since JWTs are only base64-encoded, not encrypted. This means sensitive information in the payload is potentially exposed.
-
-The JWT consists of three parts:
-
-
-
-In the above example you can see that they are:
-
-- Header: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9`
-- Payload: `eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJlbWFpbCI6ImhlbGxvQHdvcmxkLmNvbSJ9`
-- Signature: `EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0`
-
-The Split Token approach provides a solution by:
-
-1. Separating the JWT into its three component parts: header, payload, and signature
-2. Storing only the signature on the client side (which by itself is meaningless)
-3. Keeping the header and payload securely on the server side (in Tyk)
-4. Reconstructing the complete JWT when needed for authentication
-
-This approach combines the benefits of JWTs (rich claims, stateless validation) with the security of opaque tokens (no information disclosure).
-
-### When to Use Split Token Flow
-
-Consider using Split Token Flow when:
-
-- Your JWT payload contains sensitive information that shouldn't be exposed to clients
-- You want to prevent token inspection by malicious actors
-- You need the flexibility of JWT while maintaining higher security
-- You're implementing systems that must meet strict security compliance requirements
-
-### How Split Token Flow Works
-
-Here's how the process works with Tyk Gateway:
-
-1. Token Issuance:
-
- - A `/token` endpoint is configured on Tyk from which the client should request the access token
- - Tyk requests an access token from an authorization server (e.g., Keycloak) on behalf of the client
- - The authorization server returns a complete JWT
- - Tyk intercepts this response through a Virtual Endpoint
- - Tyk splits the JWT into its components and stores the header and payload in its Redis database
- - Only the signature portion is returned to the client as an "opaque" token
-
-2. Token Usage:
-
- - The client makes API requests using only the signature as their access token
- - Tyk receives the request and looks up the stored header and payload using the signature
- - Tyk reconstructs the complete JWT and validates it
- - If valid, Tyk forwards the request to the upstream API with the full JWT
-
-3. Security Benefits:
-
- - The client never possesses the complete JWT, only a meaningless signature
- - Token contents cannot be inspected by client-side code or malicious actors
- - Token validation still occurs using standard JWT verification
-
-
-### Implementing Split Token Flow
-
-1. **Create a Virtual Endpoint for Token Issuance**
-
- First, create a virtual endpoint in Tyk that will:
-
- - Receive authentication requests from clients
- - Forward these requests to your authorization server
- - Split the returned JWT
- - Store the header and payload in Tyk's storage
- - Return only the signature to the client
- - Here's a simplified implementation:
-
- ```javascript
- function splitTokenHandler(request, session, config) {
- // 1. Forward the client's credentials to the authorization server
- var authServerResponse = forwardToAuthServer(request);
-
- if (authServerResponse.Code !== 200) {
- return TykJsResponse({
- Body: authServerResponse.Body,
- Code: authServerResponse.Code
- }, session.meta_data);
- }
-
- // 2. Extract the JWT from the response
- var responseBody = JSON.parse(authServerResponse.Body);
- var fullJWT = responseBody.access_token;
-
- // 3. Split the JWT into its components
- var jwtParts = fullJWT.split(".");
- var header = jwtParts[0];
- var payload = jwtParts[1];
- var signature = jwtParts[2];
-
- // 4. Store the complete JWT in Tyk's Redis database using the signature as the key
- // This function would use Tyk's storage API to save the data
- storeJWTComponents(signature, header, payload, fullJWT);
-
- // 5. Modify the response to return only the signature
- responseBody.access_token = signature;
-
- return TykJsResponse({
- Body: JSON.stringify(responseBody),
- Code: 200
- }, session.meta_data);
- }
- ```
-
- Note that this example includes some level of abstraction for clarity and so is not a full implementation.
-
-2. **Configure Custom Pre-Auth Plugin**
-
- Next, create a custom pre-auth plugin that reconstructs the JWT before it reaches the standard Tyk JWT Auth middleware:
-
- ```javascript
- function reconstructJWT(request, session, config) {
- // 1. Extract the signature from the Authorization header
- var authHeader = request.Headers["Authorization"];
- var signature = authHeader.replace("Bearer ", "");
-
- // 2. Retrieve the stored JWT components using the signature
- var storedJWT = retrieveJWTComponents(signature);
-
- if (!storedJWT) {
- return TykJsResponse({
- Body: "Invalid token",
- Code: 401
- }, session.meta_data);
- }
-
- // 3. Replace the Authorization header with the full JWT
- request.SetHeaders["Authorization"] = "Bearer " + storedJWT.fullJWT;
-
- return request;
- }
- ```
-
-3. **Test the Implementation**
-
- To test your Split Token Flow:
-
- Request a token from your Tyk virtual endpoint:
-
- ```bash
- curl -X POST https://your-tyk-gateway/token \
- -d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"
- ```
-
- You'll receive a response with only the signature as the access token, for example:
-
- ```json
- {
- "access_token": "EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0",
- "token_type": "bearer",
- "expires_in": 3600
- }
- ```
-
- Use this token to access your JWT Auth protected API where you have configured the custom pre-auth plugin and JWT Auth:
-
- ```bash
- curl https://your-tyk-gateway/protected-api \
- -H "Authorization: Bearer EwIaRgq4go4R2M2z7AADywZ2ToxG4gDMoG4SQ1X3GJ0"
- ```
-
-
diff --git a/docs.json b/docs.json
index a9341166f..35d0d0e9c 100644
--- a/docs.json
+++ b/docs.json
@@ -333,8 +333,16 @@
"group": "JSON Web Tokens",
"pages": [
"basic-config-and-security/security/authentication-authorization/json-web-tokens",
+ "api-management/authentication/jwt-quick-start",
+ "api-management/authentication/jwt-signature-validation",
"api-management/authentication/jwt-claim-validation",
- "api-management/authentication/jwt-authorization"
+ "api-management/authentication/jwt-authorization",
+ {
+ "group": "Guides",
+ "pages": [
+ "api-management/authentication/jwt-split-token"
+ ]
+ }
]
},
"basic-config-and-security/security/authentication-authorization/hmac-signatures",