liveBook · Manning

JWT header

As explained in Secure APIs

A token header is the metadata-bearing section of a JWT that identifies properties such as its signing algorithm.

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

How Secure APIs covers it

How deep it goes
Explains header fields, base64url placement, key selection, and algorithm constraints without detailing cryptographic implementation.
Examples
Shows JSON headers using typ, alg, and kid, including RS256 and HS256 signing-algorithm examples.
What it assumes
Assumes familiarity with access tokens while defining JWT structure, header fields, and their validation role.
What you can do after
Evaluate JWT metadata by reading typ, alg, and kid, then relate alg and kid to signature validation.
How it connects
Connects JWTs with JOSE, payloads, signatures, signing algorithms, signing keys, OIDC providers, and JWKS endpoints.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.