What it means
A JSON Web Token, or JWT, is a way to hand a set of claims from one system to another. A claim is a statement such as who the user is, who issued the token, who it is for, and when it expires. In the signed form, the header names the signing algorithm and the signature covers the header and the claims. The parts are encoded, not encrypted, so anyone holding a token can read it. A receiver must choose the algorithm and key from its own configuration, verify the signature, and then check issuer, audience and expiry. Each check answers a different question.
See the idea / Identity
A valid signature is one JWT check of several.
Follow the gateway’s four checks on one token: algorithm, signature, issuer and audience, then time. A correctly signed token can still be refused.
Meridian’s sign-in gateway is the service at sso.chronos.orbital. It accepts tokens from one identity provider, https://idp.kestrel.example, signed with the RS256 algorithm. It holds that provider’s public key, pinned under key ID k1. Compare a token issued for the gateway with a token issued for the staging wiki.
01 / 04
Algorithm
The gateway reads the token header. It says RS256, which is on the gateway’s own allow list. The header does not get to choose the algorithm.
More about this step
The header is the first of three base64url parts. Decoded, it reads alg RS256, kid k1, typ JWT. Encoded, it is eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIiwidHlwIjoiSldUIn0. The gateway compares alg with a list set in its own configuration. A header that said none, or HS256, would be refused here. Accepting HS256 would let an attacker sign a token using the public key as a shared secret.
Step through at your own pace.
Keep in mindOne provider, one key and one signed token. Key rotation, the nonce, replay tracking, revocation and encrypted tokens are not shown. Libraries differ in the order of these checks. What matters is that every one passes before any claim is used. Passing them shows who issued the token and for which service. It does not decide what the user may do.
Read the visual, step by step
Token for the gateway
- Algorithm. The gateway reads the token header. It says RS256, which is on the gateway’s own allow list. The header does not get to choose the algorithm. The header is the first of three base64url parts. Decoded, it reads alg RS256, kid k1, typ JWT. Encoded, it is eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIiwidHlwIjoiSldUIn0. The gateway compares alg with a list set in its own configuration. A header that said none, or HS256, would be refused here. Accepting HS256 would let an attacker sign a token using the public key as a shared secret.
- Signature. The gateway verifies the signature with pinned key k1. It is valid, so the header and claims are exactly what the provider signed. The signature covers the encoded header, a period and the encoded claims. The gateway uses the provider’s public key that it pinned under key ID k1. A valid signature shows the bytes are unchanged and came from the holder of the provider’s private key. It says nothing yet about who the token is for.
- Issuer, audience. The issuer claim, iss, names the expected provider. The audience claim, aud, names this gateway. The token was issued by the right party, for this service. The claims are iss https://idp.kestrel.example and aud sso.chronos.orbital. The gateway compares each with the exact value it expects. A partial match or a pattern would not be enough. Here the gateway’s audience value is its host name. Many providers use the client ID instead. Either way the match is exact.
- Time. The token expires at 09:05:00 UTC and the gateway’s clock reads 09:00:40. All four checks have passed, so the gateway accepts the claims. The exp claim is 1794992700, which is 09:05:00 UTC on November 18, 2026, counted in seconds since 1970. The gateway allows 60 seconds of clock difference. Only now does it read the other claims, such as the user’s identifier.
Token for the wiki
- Algorithm. The gateway reads the token header. It says RS256, which is on the gateway’s own allow list. The header does not get to choose the algorithm. The header is the first of three base64url parts. Decoded, it reads alg RS256, kid k1, typ JWT. Encoded, it is eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIiwidHlwIjoiSldUIn0. The gateway compares alg with a list set in its own configuration. A header that said none, or HS256, would be refused here. Accepting HS256 would let an attacker sign a token using the public key as a shared secret.
- Signature. The gateway verifies the signature with pinned key k1. It is valid, so the header and claims are exactly what the provider signed. The signature covers the encoded header, a period and the encoded claims. The gateway uses the provider’s public key that it pinned under key ID k1. A valid signature shows the bytes are unchanged and came from the holder of the provider’s private key. It says nothing yet about who the token is for.
- Issuer, audience. The issuer claim, iss, names the expected provider. The audience claim, aud, says wiki-staging. This token was issued for a different service, so the gateway refuses it. The token is real and correctly signed. Someone took it from the staging wiki and sent it to the gateway. The audience claim is the only thing that shows the difference, which is why a valid signature is not enough.
- Stop. The gateway stops. The time check does not run, and no other claim in the token is read or used. A refusal at any check ends the process. The gateway logs the refusal with the audience it saw. It does not sign anyone in with reduced rights.
One provider, one key and one signed token. Key rotation, the nonce, replay tracking, revocation and encrypted tokens are not shown. Libraries differ in the order of these checks. What matters is that every one passes before any claim is used. Passing them shows who issued the token and for which service. It does not decide what the user may do.
Flow references: RFC 7519: JSON Web Token · RFC 8725: JSON Web Token Best Current Practices
AN ILLUSTRATIVE SCENARIO
Signed correctly, sent to the wrong service
Meridian's sign-in gateway accepts tokens from one identity provider, signed with RS256. A token arrives that the provider really signed. The gateway's algorithm check passes and the signature verifies. The aud claim, though, says wiki-staging. Someone has taken a token issued for the staging wiki and sent it to the gateway. The gateway refuses it. It does not check the time or use any other claim.
Put it to work
- Configure your verifier with a fixed list of allowed algorithms and the issuer's keys, so nothing in a token's header can choose either.
- Require exact matches for the issuer and the audience, and reject a token when either claim is missing.
- Enforce the expiry time with a small allowance for clock difference, keep token lifetimes short, and put no secrets in the claims.
How to check your work
Send your service five test tokens: unsigned with alg none, signed with the wrong key, wrong issuer, wrong audience, and expired. Each must be refused. Then confirm a correct token is accepted.
Connect the ideas
- OpenID Connect
An identity layer on OAuth. An identity provider issues an ID token that asserts a sign-in. The application still checks the audience and still decides what that account may do.
- OAuth
A delegated-access framework: a client presents an access token so a resource server can allow a limited action. The token is not proof of who the human is, and it does not grant every action the API could perform.
- Federation
Trusting authentication assertions from an external identity provider instead of storing every password locally.
- HMAC
A short tag computed from a message and a shared secret key with a hash function. A receiver holding the same key recomputes the tag to check that the message is unchanged and came from a key holder.