You can create an API token compliance validation rule by adding a custom JSON Web Token (JWT) and binding it to the API that requires verification. ESA will then perform token compliance validation on incoming requests and process them to secure your business APIs.
Configure an API token rule
In the ESA console, choose Websites. In the Website column, click the target website.
In the left-side navigation pane, choose .
On the API Security page, click the API Rules tab, and then click Token Configuration.

Click Add to create a token configuration.

Configure the token parameters, and then click OK:
Configuration Name: Enter a custom name for the configuration, such as
JWT-Demo.Token Location: Select the location of the token in the request. You can select Header or Cookie and enter the corresponding key name.
NoteTo check for tokens in multiple locations, click Or to create a logical
ORcondition. ESA can check up to four locations simultaneously.Token Key: Add a token key by entering it manually or uploading a JSON file. For key requirements, see Token details.
NoteIf you configure multiple keys, ESA uses the
kidfield to select a key for validation. The request passes validation if it matches any of the keys.

After configuring the token, return to the API Rules tab and click Add Rule to create an API rule.

Configure the following token validation parameters:
Rule Name: Enter a custom name for the rule, such as
rule-jwt-demo.Verify API: Click the drop-down list to select the hostname for token compliance verification. ESA will then automatically display the list of APIs under the selected hostname. Review and select the required APIs.
Select Token Configuration: Select one or more token configurations. If you select multiple configurations, choose one of the following options:
Validate at least one: The request must match at least one of the selected token configurations. Otherwise, the request is considered non-compliant.
Validate all: The request must match all of the selected token configurations. Otherwise, the request is considered non-compliant.
NoteBy default, ESA considers requests without a token non-compliant. To allow requests that are missing a specific token, select Ignore from the drop-down list in the If No Token column for the corresponding token.
Action: Select an action for requests that fail token validation:

Verify the results
After creating an API rule, navigate to . On the Events page, filter by the API Rule protection rule type. View detailed protection logs in the Sampling Logs section.
Token details
Token validation currently supports only JWT verification.
Field descriptions
The public key must be in JSON Web Key (JWK) format and contain the kid and alg fields.
kty: The key type, for example,ECfor an Elliptic Curve key.use: The intended use of the public key, for example,sigindicates that the key is used for digital signatures.crv: The type of elliptic curve, for example,P-256for the NIST-standardized P-256 curve.kid: A custom key identifier, such asesa. The JWK must contain thekidfield for key selection. Similarly, the JWT in the request must also contain akidclaim. This field enables token key rotation.x: The x-coordinate of the elliptic curve public key.y: The y-coordinate of the elliptic curve public key.alg: The algorithm identifier. Currently, onlyES256(ECDSA with SHA-256) is supported.
Example
{
"kty": "EC",
"use": "sig",
"crv": "P-256",
"kid": "esa",
"x": "QG3VFVwUX4IatQvBy7sqBvvmticCZ-eX5-nbtGKBOfI",
"y": "A3PXCshn7XcG7Ivvd2K_DerW4LHAlIVKdqhrUnczTD0",
"alg": "ES256"
}
