Unify Logo Footer.svg
API Manager
Logo
JWT Validation Policy

JWT Validation Policy

Logo

4 mins READ

Verify the authenticity and integrity of JSON Web Tokens on incoming API requests before forwarding them to the backend.

Overview

JWT Validation Policy verifies the authenticity and integrity of JSON Web Tokens (JWTs) included in API requests. Only requests carrying a valid, trusted token are forwarded to backend services. The policy validates the token's signature, algorithm, and claims — enforcing authentication and authorization requirements at the gateway level.

jwt.png
jwt.png

Field Reference

Field

Description

Policy Name *

A unique identifier used across logs, dashboards, and API group configurations.

Tags

Custom labels to organize and filter the policy by environment, team, or functionality.

JWT Header Key *

The HTTP header where the JWT token is expected (e.g., Authorizationx-access-token).

Algorithm *

The cryptographic algorithm used to verify the JWT signature. Supported: RS256, RS384, RS512 (RSA-based); HS256, HS384, HS512 (HMAC-based).

RSA Public Key *

The public key used to verify JWT signatures when using an RSA algorithm. Must be in PEM format (PKCS1 or PKCS8).

Reserved Claims to Enforce

Standard JWT claims that must be validated (e.g., issaudsub). Note: expnbf, and iat are validated automatically.

Custom Claims to Enforce

Additional custom claims that must be present and match expected values. Each custom claim requires a Claim Name and Expected Value.

jwt-1.png
jwt-1.png

How It Works

  1. Request received — The gateway receives the API request containing a JWT.

  2. Token extraction — The JWT is extracted from the configured HTTP header.

  3. Signature validation — The token's signature is verified using the configured algorithm and key.

  4. Claims validation — Default claims (expnbfiat) are validated automatically. Configured reserved and custom claims are then checked.

  5. Validation outcome — Valid tokens allow the request through to the backend. Invalid or missing tokens result in an error response to the caller.

Attaching to an API Group

Once a JWT Validation Policy is created, attach it to one or more API Groups from the group's policy settings. Multiple policies can be applied to a single group; drag them into the desired execution order.

Notes

  • Place this policy early in the execution order — authenticating requests before rate limiting or transformation avoids unnecessary processing for unauthenticated callers.

  • RSA-based algorithms (RS256, RS384, RS512) are preferred for production: the private key used to sign tokens stays on the issuer, and only the public key is shared with the gateway.

  • Use Custom Claims to enforce tenant or role membership (e.g., tenant_id must equal acme-corp) to prevent cross-tenant access at the gateway level.

  • Rotate RSA key pairs periodically and update the RSA Public Key in the policy before the old private key is retired to avoid downtime.

FAQs

What claims are validated automatically?

The policy automatically validates exp (expiration), nbf (not before), and iat (issued at) claims. You do not need to add these to Reserved Claims to Enforce

Do I need to configure a public key for HMAC algorithms?

No. The RSA Public Key field applies only to RSA-based algorithms (RS256, RS384, RS512). For HMAC algorithms (HS256, HS384, HS512), the shared secret key is used instead — configure the appropriate key field for your chosen algorithm.

What happens if the JWT is missing from the request?

If the configured JWT Header Key is absent from the request, the gateway rejects the request with an authentication error. The backend automation is not invoked.

Can I enforce that a JWT was issued by a specific identity provider?

Yes. Add iss to Reserved Claims to Enforce. The policy will reject tokens whose issuer does not match the expected value.