Blog post: Building your own OIDC provider
Problem
OIDC endpoint support is only the protocol core. A production-shaped provider must also make identity, keys, clients, consent, tokens, and operations durable and secure.
Responsibilities
- Publish discovery metadata and JWKS.
- Implement authorization code with PKCE, refresh token, and client credentials where appropriate.
- Persist registered clients, authorizations, consents, users, and authorities.
- Use an immutable identifier for
sub; keep mutable usernames in a separate claim. - Persist and rotate signing keys while retaining keys needed to validate existing tokens.
- Separate browser/session security from stateless protocol and administrative APIs.
- Restrict client authentication methods and avoid secrets in request bodies.
- Rate-limit login, token, introspection, and user-info endpoints.
- Provide revocation, health probes, audit logs, and explicit production startup validation.
Gotchas
A provider that generates a signing key at every restart invalidates tokens in flight. Disabling CSRF globally to simplify token endpoints also weakens browser-facing session routes. Treat these as separate security domains.