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.
3 points to say:
- The header holds
alg,kid; the payload holds claimsiss,sub,aud,exp,scope; never put sensitive data in the payload. - The minimal correct config:
issuer-uri(finds JWKS, checksiss) +audiences(checksaud). - 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.