Blog post: Spring Authorization Server: from zero to a working OIDC provider

Protocol surface

Verify discovery, authorization, token, JWKS, introspection, revocation, and UserInfo endpoints. Enable only the grant types and scopes each registered client needs.

Persistence

Back these contracts with durable storage:

  • RegisteredClientRepository
  • OAuth2AuthorizationService
  • OAuth2AuthorizationConsentService
  • UserDetailsService

Manage schemas with migrations and refuse production startup when required secrets or database settings are absent.

Security checklist

  • Persist RSA or EC signing keys and rotate them without dropping still-valid public keys.
  • Map sub to an immutable UUID, not a username.
  • Keep browser login and consent routes session-based with CSRF protection.
  • Keep token and administrative APIs stateless with explicit 401 responses.
  • Prefer client_secret_basic; avoid client_secret_post logging exposure.
  • Require PKCE for public clients.
  • Rate-limit credential-bearing endpoints.
  • Use separate development seed data and production configuration.

End-to-end verification

Complete a full authorization-code roundtrip, validate the ID token, call UserInfo, refresh where permitted, revoke the token, and confirm the revoked credential is rejected.