Enhance Transform Rules
You can forward information from a JSON Web Token (JWT) to the origin in a header by creating Transform Rules using claims that Cloudflare has verified via the JSON Web Token.
Claims are available through the http.request.jwt.claims
firewall fields.
For example, the following expression will extract the user claim from a token processed by the Token Configuration with TOKEN_CONFIGURATION_ID
:
Refer to Configure JWT Validation for more information about creating a Token Configuration.
As an example, to send the header x-send-jwt-claim-user
request header to the origin, you must create a Transform Rule:
- Log in to the Cloudflare dashboard ↗ and select your account and domain.
- Go to Rules > Transform Rules.
- Select Modify Request Header > Create rule.
- Enter a rule name and a filter expression, if applicable.
- Choose Set dynamic.
- Set the header name.
- Set the value to
lookup_json_string(http.request.jwt.claims["<TOKEN_CONFIGURATION_ID>"][0], "claim_name")
, where<TOKEN_CONFIGURATION_ID>
is your token configuration ID found in JWT Validation andclaim_name
is the JWT claim you want to add to the header.