SteelReed

Search

Search posts, questions…

SecurityQuestion 11 / 24

Middle

What is the structure of a JWT, and how does Spring Security's OAuth2 Resource Server process one?

Short answer

A JWT (JWS) is header.payload.signature, three base64url parts: anyone can read the payload, the signature only stops tampering. Spring Resource Server takes the token from the header, JwtDecoder verifies signature and claims, then maps scope to authorities.

badvalidAuthorization: Bearer ...BearerTokenAuthenticationFilterJwtDecoder: key by kidsignature, exp, iss, aud401 invalid_tokenscope to SCOPE_ authorityAuthorizationFilter checksrules

3 points to say:

  1. The header holds alg, kid; the payload holds claims iss, sub, aud, exp, scope; never put sensitive data in the payload.
  2. The minimal correct config: issuer-uri (finds JWKS, checks iss) + audiences (checks aud).
  3. Bad token → 401 with WWW-Authenticate; valid token without permission → 403.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.