Identity Protocol: A Deep Dive into OpenID Connect (OIDC)
OAuth 2.0 is for Authorization (accessing a resource). OIDC is for Authentication (proving who you are).
The ID Token
The core of OIDC is the ID Token, a signed JWT that contains user "Claims" (Email, Name, Profile). Unlike an Access Token, the ID Token is meant to be read by the client.
The Flow of Trust
- Authorization Request: Client asks the Identity Provider (IdP) for identity.
- User Consent: User signs in via a secure SSO page.
- Token Exchange: Client receives an ID Token and verifies its signature using the IdP's public keys (JWKS).
Security Best Practices
- Always use the 'Authorization Code' flow with PKCE.
- Never store ID Tokens in LocalStorage (use Secure/HttpOnly cookies).
- Validate the 'aud' (Audience) claim to prevent token replay attacks.