A JWT header, also called a JOSE header, is the metadata section of a JSON Web Token. It identifies properties such as the token type, signing algorithm, and signing key identifier. A JWT combines base64url-encoded header, payload, and signature parts with dots. section 7.2.2
Listing 7.1 Example JOSE header
{
"typ": "JWT",
"alg": "RS256",
"kid": "080E8CtRFAnnLlgK3dk8Y"
}
Use the example header to see the three commonly used fields: typ identifies the token as a JWT, alg names the signing algorithm, and kid identifies the signing key or secret. section 7.2.2
Read the main header fields as follows:
- typ describes the media type; for this token, it is JWT. section 7.2.2
- alg identifies the algorithm used to sign the token, such as RS256 or HS256. section 7.2.2 section 8.7
- kid identifies the key or secret used for signing, allowing a validator to locate the corresponding verification key. section 7.2.2 section 8.7
The header helps a server choose how to validate a token’s signature. Because attackers may manipulate the alg field, implementations should constrain the allowed signing algorithm instead of blindly accepting the header’s choice. With an OIDC provider, the kid value helps select the verification key from the provider’s JWKS endpoint. section 8.7
An access-token header
A header containing typ JWT, alg RS256, and a kid value tells the validator that the token is a JWT signed with RS256 and identifies which signing key to use. The payload and signature still require separate validation. section 7.2.2 section 7.8
