Skip to main content
The JWT Validation Traffic Policy action enables you to validate JSON Web Tokens (JWT) on your endpoints before routing traffic to your upstream service.
See this guide for specific instructions on configuring this action with Auth0.
You can use jwt.io to work with JWTs.

Configuration reference

The Traffic Policy configuration reference for this action.

Supported phases

on_http_request

Type

jwt-validation

Configuration fields

Behavior

Request validation

ngrok allows the request only if the issuer correctly signed it and the defined claims match. For efficient token validation, include the optional kid claim in your JWTs and JWK payload. You can implement custom validation in Traffic Policies with the actions.ngrok.jwt_validation.tokens action result variable and its corresponding properties.

Multiple issuers

You can specify multiple issuers for JWT validation. ngrok considers a request valid if it presents a JWT signed by any of the specified issuers. The issuer must exactly match the one provided in the JWT, including any trailing slashes (/) present in the iss claim.

Multiple audience claims

You can optionally specify one or more audience (aud) claims for JWT validation. If present, the aud claim must contain at least one of the specified audience claims and exactly match for validation to succeed.

Multiple signing keys

You can provide multiple JSON Web Key Set (JWKS) URLs and signing algorithms. During JWT validation, ngrok tries the JWKS and algorithms you provide, in order, to validate the JWT. ngrok caches the list for performance and refreshes the cache roughly every 15 minutes, or less often when the JWKS response sets a longer Cache-Control: max-age or Expires.

Multiple tokens

If you define multiple tokens within the HTTP configuration parameter, all tokens must be present in the request. If any token is missing, ngrok returns a 401 Unauthorized status code.

Non-terminating action

This is a Non-terminating action. It does not return a response, and will allow Traffic Policy processing to continue to the next Action in the chain. All Cloud Endpoint Traffic Policies must end with a terminating action. This requirement does not apply to Agent Endpoints.

Examples

Basic example

The following Traffic Policy configuration is an example configuration of the jwt-validation action. For a more real-world example, check out the Auth0 guide.

Example Traffic Policy document

Example request

In this example, a request is sent to the API with a valid JWT token in the Authorization header with the Bearer prefix and getting back a 200 OK response.

Action result variables

The following variables are made available for use in subsequent expressions and CEL interpolations after the action has run. Variable values will only apply to the last action execution, results are not concatenated.