liveBook · Manning

JSON Web Token

As explained in Grokking Software Architecture

JWT is a compact, URL-safe token format for representing claims that can be digitally signed or encrypted.

A JWT carries identity and role claims from an identity provider to an API. After login, the browser attaches the token to API requests; the gateway verifies its signature before allowing them through. section 11.3.2

A secure JWT check should:

  • Verify the signature using public keys fetched from the identity provider’s JWKS endpoint. section 11.3.2
  • Check the exp claim so an expired token is rejected. section 11.3.2
  • Pin the allowed algorithm; accepting an attacker-selected algorithm can enable forged tokens. section 11.3.2

Reading is not verifying

Decoding a token to read a user ID does not establish that it is trustworthy. A forged token could claim admin status, so backend routes must authorize requests using a cryptographically verified token—not a role supplied by the user or a hidden frontend button. section 11.3.2 section 11.6

Figure 11.3 The IdP issues the "Royal Seal" (JWT), which the API Gateway verifies to ensure the user is who they claim to be.

The diagram traces the JWT from identity provider to API gateway and shows where verification fits. section 11.3.2

How Grokking Software Architecture covers it

How deep it goes
Traces issuance and gateway verification, then names JWKS, expiry, and algorithm checks without detailing implementation code.
Examples
Uses a User-role login, forged admin claims, browser API requests, and the none-algorithm failure.
What you can do after
Diagnose token-handling risks by checking JWKS signatures, validating exp, pinning the algorithm, and enforcing backend authorization.
How it connects
Connects identity providers, OAuth/OIDC, API gateways, JWKS, and backend authorization.

Also explained in

Compare how 13 books explain JSON Web Token →

Related concepts

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