OAuth2 and OpenID Connect
22 questions in 7 subtopics.
OAuth2 flows
What is the difference between OAuth2 and OpenID Connect? What does the ID token contain and why should an API not accept it as an access token?Which OAuth2 grant would you use for each case and why: (1) a server-rendered web app logging users in, (2) a single-page app, (3) a nightly batch job calling an API, (4) a smart TV app? Which grants should no longer be used?Design the identity architecture for a company with a web app, mobile apps, partner APIs and 60 internal microservices. Which flows, token types and trust boundaries would you define?Resource server with JWT
Configure a Spring Boot service as an OAuth2 resource server that accepts JWTs from https://idp.example.com/realms/shop, only accepts tokens with audience orders-api, and maps the "roles" claim to ROLE_ authorities.A resource server rejects every token with "The iss claim is not valid" even though tokens come from the right identity provider. What would you check?After the identity provider rotated its signing keys, some pods of a resource server reject valid tokens with 401 invalid_token and "Signed JWT rejected: Another algorithm expected, or no matching key(s) found" while other pods accept them. How do you analyse it?Your company is moving 50 services from a legacy token format to OAuth2 JWT access tokens issued by a new identity provider. How would you plan the migration so no service breaks?After a merger, your company has two identity providers with different token formats and claims, and services must accept users from both. What long-term identity architecture would you aim for?Opaque tokens
Compare JWT access tokens with opaque tokens checked by token introspection. How do you configure introspection in Spring Security, and what does it cost?Your security team wants immediate token revocation for all APIs, but service owners worry about latency and IdP load. How would you design a solution?OAuth2 client
A Spring Boot service needs to call a partner API using the client credentials grant. How do you configure the client registration and haveRestClient attach and refresh the token automatically?A React single-page app talks to several Spring APIs. The team stores access and refresh tokens in localStorage. Propose a safer design with Spring and explain why.Your company wants to open its APIs to third-party developers and partners. What identity and OAuth2 strategy would you set for this developer ecosystem over the long term?Spring Authorization Server
What is Spring Authorization Server, what are its main configuration pieces, and when would you run it instead of buying an identity provider?You run Spring Authorization Server for 200 clients. You must rotate the token signing key without downtime. What is the procedure?Should your company build its own identity platform on Spring Authorization Server or buy a commercial identity provider? Make the case for both and how you would decide.PKCE
Explain how PKCE works step by step and which attack it prevents. When does Spring Security's OAuth2 client use PKCE?A security review says your confidential server-side web client must use PKCE even though it has a client secret. Is the reviewer right, and how do you enable it in Spring Security?OAuth and identity standards have changed several times in 15 years (implicit flow, then PKCE, then BFF recommendations, now passkeys). How should a company keep its identity posture current without constant rewrites?Keycloak
Configure a Spring Boot 3 API as a resource server for tokens issued by a Keycloak realm 'shop', and map Keycloak realm roles from the token to Spring Security authorities so@PreAuthorize("hasRole('ADMIN')") works.You run a Keycloak cluster for 120 applications. After a Keycloak upgrade, logins slow down and some sessions are lost when a node restarts. What do you investigate, and how do you operate Keycloak reliably?Your company considers moving from a self-hosted Keycloak to a commercial identity provider, or staying and investing in Keycloak. How do you structure the decision?No question matches these choices.