Enhance Request Header Transform Rules
import { Steps, DashButton } from "~/components";
You can forward verified claims from a JSON Web Token (JWT) to your origin in a header by creating a Request Header Transform Rule.
Verified claims are available to Request Header Transform Rules through the http.request.jwt.claims fields. They are not available to URL Rewrite Rules.
For example, the following expression will extract the user claim from a token processed by the token configuration with TOKEN_CONFIGURATION_ID:
lookup_json_string(http.request.jwt.claims["<TOKEN_CONFIGURATION_ID>"][0], "claim_name")
Refer to Configure JWT validation for more information about creating a token configuration.
Create a Request Header Transform Rule
As an example, create a Request Header Transform Rule to send the x-send-jwt-claim-user request header to the origin:
<DashButton url="/?to=/:account/:zone/rules/overview" />
- Select Create rule > Request Header Transform Rules.
- Enter a rule name and a filter expression, if applicable.
- Choose Set dynamic.
- Set the header name to
x-send-jwt-claim-user. - Set the value to:
lookup_json_string(http.request.jwt.claims["<TOKEN_CONFIGURATION_ID>"][0], "claim_name")<TOKEN_CONFIGURATION_ID>is your token configuration ID found in JWT validation andclaim_nameis the JWT claim you want to add to the header.
这篇文档对你有帮助吗?
谢谢你的反馈!