Archived. This page shows content that now lives in the Spring Security Guide. It stays here so old links keep working, but it is no longer updated.
Each concept as app screens and numbered arrows: follow the numbers, read the label on each hop, then the steps below. Examples use invented apps (ShopEasy, IDHub) and your own project (Postman, Auth Server :9000, Services A and B).
A hotel: the front desk checks your ID (who are you?), then gives a key card that opens only your room (what may you do?).
In Spring: Authentication filters + AuthenticationManager answer step 1; AuthorizationFilter with hasAuthority(...) answers steps 3–4.
Say it in the interview: Authentication proves who you are (401 on failure); authorization decides what you may do (403 on failure).
An airport: every passenger walks through checkpoints in a fixed order before reaching the gate. Your controller is the gate.
In Spring: Several chains can exist; @Order + securityMatcher decide which one handles a URL (your Auth Server has two).
Say it in the interview: Security is a chain of servlet filters in front of the DispatcherServlet; rejected requests never reach the controller.
A gym: you show your membership once at the entrance, get a wristband, and the staff just check the wristband after that.
In Spring: formLogin() adds UsernamePasswordAuthenticationFilter; your Auth Server uses this for nithin before the consent screen.
Say it in the interview: Form login is stateful: identity lives in a server session, and a cookie points to it — which is why CSRF protection matters here.
A sealed envelope: anyone can read the letter through the window, but only the issuer's wax seal proves nobody changed it.
In Spring: Resource server: JwtDecoder (from issuer-uri) verifies signature, iss and exp; public key comes from /oauth2/jwks.
Say it in the interview: A JWT is Base64-encoded, not encrypted; its security is the signature, so never put secrets in the payload.
"Log in with IDHub" on a shopping app: you type your password only on IDHub's page; the app gets a code, then trades it for a token behind the scenes.
In Spring: Your project: Postman = app, :9000 = provider, Service A/B = API. Auth Server beans ①–⑦ handle steps 1–6; Service A/B do step 7.
Say it in the interview: Your image shows the token coming back at step 3; in Authorization Code the browser only gets a code, and the token comes on the back channel (steps 5–6). Token-in-the-browser was the old implicit flow, now deprecated.
A delivery van with a company badge: nobody logs in; the van shows its own badge at the gate every night.
In Spring: Job side: spring-boot-starter-oauth2-client + AuthorizedClientServiceOAuth2AuthorizedClientManager (no HTTP request in a scheduler).
Say it in the interview: Use the user's token when a user acts; use client credentials when the application acts by itself.
A shop checks banknotes with a UV lamp it bought once from the central bank, instead of phoning the bank for every note.
In Spring: spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:9000 — Spring finds /.well-known/openid-configuration, then jwks_uri.
Say it in the interview: That's why an Auth Server outage doesn't break existing tokens, and why a restarted Auth Server (new key) makes old tokens fail.
A signed permission slip passed from the front office to the back office: the back office checks the same signature itself.
In Spring: ServletBearerExchangeFilterFunction (MVC) or ServerBearerExchangeFilterFunction (WebFlux) on A's WebClient.
Say it in the interview: Defense in depth: B trusts nobody by network position; even a direct call to B needs a valid token.
Club door: no ID → turned away (401). ID fine but VIP room only → turned away from that room (403).
In Spring: ExceptionTranslationFilter: AuthenticationEntryPoint → 401, AccessDeniedHandler → 403. Customize both for clean JSON bodies.
Say it in the interview: 401 means 'I don't know who you are'; 403 means 'I know you, but you're not allowed'.
A day pass (access token) expires every hour; a membership card (refresh token) at the desk gets you a new day pass without re-registering.
In Spring: Auth Server: add AuthorizationGrantType.REFRESH_TOKEN to the client; TokenSettings.refreshTokenTimeToLive(...). Not used for client credentials.
Say it in the interview: Short access token for safety, long refresh token for convenience; the refresh token only ever goes to the Auth Server.
Someone slips a pre-signed withdrawal form into your pile of mail; the bank accepts it because it carries your signature stamp (the cookie).
In Spring: On by default. Your A and B disable it because they use Bearer tokens in a header, which browsers never attach automatically.
Say it in the interview: CSRF exploits automatic cookies; APIs authenticated by an Authorization header aren't exposed, so stateless APIs can turn it off.
A security guard at the building door phones the other office: 'Visitor from shop.com — do you accept them?' Only a yes lets them in.
In Spring: http.cors(...) + a CorsConfigurationSource bean. Postman and server-to-server calls ignore CORS; only browsers enforce it.
Say it in the interview: CORS is enforced by the browser, not the server; it protects users, and it's not a replacement for authentication.