JWT
18 questions in 5 subtopics.
JWT structure
Describe the structure of a JWT and the meaning of the registered claims iss, sub, aud, exp, nbf, iat and jti. Is the payload of a signed JWT secret?What claims would you put in access tokens for your APIs, and what would you keep out? A team wants to add the user's full permission list, email, address and account balance.Different teams interpret access token claims differently: some read roles from "roles", others from "groups", and tenant ids appear in three formats. Define a claims contract for your organisation's tokens.Your platform passes user identity between dozens of internal services and several partner companies using JWTs. Looking ahead several years, how would you design identity propagation so trust stays explicit as the number of parties grows?Signature validation
Explain how a resource server validates a JWT signed with RS256 using a JWKS endpoint, and the difference from HS256.Write the configuration of aJwtDecoder bean that validates tokens from a JWKS URL, accepts only ES256, requires the issuer https://login.example.com and the audience billing-api, and allows 30 seconds of clock skew.A code review finds a hand-written JWT filter that decodes the token, reads the alg header and chooses the verification method from it. What attacks does this allow, and what should the code do?Define a token signing and validation standard for 100 services: who may sign tokens, which algorithms, how keys are published and cached, and how fast key rotation must take effect.Imagine the private key your identity provider uses to sign access tokens is suspected to be compromised. Treat this as a business continuity problem: what must already be in place, and what happens in the first hours?Expiry and refresh tokens
Why are access tokens usually short-lived while refresh tokens live longer? What is refresh token rotation and what does reuse detection add?Users of a mobile app are logged out randomly. Logs show refresh requests failing with invalid_grant shortly after another refresh succeeded. The app sends several API calls in parallel when it starts. What is happening?Set the token lifetime policy for web sessions, mobile apps and service-to-service tokens in your company. What lifetimes and rules would you choose, and how would you justify them?Product leaders want customers to stay signed in on mobile for months, while security and regulators push for stronger session controls. How would you set a long-term approach that balances user experience, fraud and compliance?Revocation
A fraud team needs to block a compromised account's JWT access tokens within one minute across 30 services. Tokens live for 15 minutes. Design a solution.Your security policy says tokens must be revocable, but your architecture relies on stateless JWT validation everywhere. How would you reconcile the policy and the architecture?JWT pitfalls
List common mistakes when using JWTs in a Spring service, such as those found in code reviews, and the correct approach for each.A team proposes replacing server sessions with JWTs stored in cookies for a server-rendered web application, saying it will make the app stateless and faster. How would you review this proposal?JWTs became the default token format across your industry. Looking at incidents over the past decade, what would you tell your architecture board about when JWTs are the right choice and when they are not?No question matches these choices.