Validate JSON Web Tokens (JWT) on your endpoints before routing traffic to your upstream service.
The JWT Validation Traffic Policy action enables you to validate JSON Web
Tokens (JWT) on your endpoints before routing traffic to your upstream service.We have created guides for configuring this action with the following providers:
Issuer URL. This can be found in the iss claim after decoding the JWT or from the /.well-known/openid-configuration endpoint in your Identity Provider.
Location in the request to expect the JWT.When choosing header, the content-type header must be set to either application/json or application/x-www-form-urlencoded.When choosing body, the method must be POST, PUT, or PATCHWe do not support including a token as a URL query parameter.
The request is allowed only if it has been correctly signed by the issuer and
the defined claims match.For efficient validation of tokens, it is recommended to include the optional
kid claim in your JWTs and JWK payload.Custom validation can be implemented in Traffic Policies via the
actions.ngrok.jwt_validation.tokens Action Result Variable and its
corresponding properties.
You can specify multiple issuers for JWT validation. A request is
considered validated 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.
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.
You can provide multiple JSON Web Key Set (JWKS) URLs and signing algorithms.During JWT validation the list of JWKS and algorithms provided will be used in
an attempt to validate the JWT. The list will be tried in order and is cached
for performance. The cache is refreshed roughly every 15 minutes.
If multiple tokens are defined within the HTTP configuration parameter, all
tokens must be present in the request. If all tokens are not present, a
401 Unauthorized status code will be returned.
The following Traffic Policy
configuration is an example configuration of the jwt-validation action. For a
more real-world example, check out our Auth0 guide.
In this example, we are sending a request to our API with a valid JWT token in
the Authorization header with the Bearer prefix and getting back a 200 OK
response.
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.