SSO, OAuth 2.0 and OpenID Connect
Learn how single sign-on and delegated access work with SAML, OAuth 2.0 and OIDC, and the misconfigurations attackers exploit.
Intermediate · about 5 hours · difficulty 3/5
Learn first: Authorization and Least Privilege, HTTP for Security Work
Employees log in once and reach dozens of apps; users click "Sign in with Google". That convenience is federated identity, and it concentrates risk in the identity provider.
The players
- Identity Provider (IdP): authenticates the user (Microsoft Entra ID, Okta, Google).
- Service Provider / Relying Party: the app that trusts the IdP.
- Tokens or assertions: signed statements from the IdP saying who the user is.
Protocols
- SAML 2.0: XML assertions, common in enterprise SSO.
- OAuth 2.0: an authorization framework for delegated access ("let this app read my calendar"). It issues access tokens, not identity.
- OpenID Connect (OIDC): an identity layer on top of OAuth 2.0 that adds an ID token (a JWT) describing the user.
Know the authorization code flow with PKCE, which is the recommended flow for web and mobile apps. The implicit flow is deprecated.
Common weaknesses
- Open redirects or loose
redirect_urimatching that leak authorization codes. - Missing
stateparameter enabling login CSRF. - Not validating token signature, audience, issuer or expiry.
- Over-broad scopes granted to third-party apps (consent phishing).
- SAML signature wrapping bugs in custom implementations.
Why defenders care
A compromised IdP account can reach every connected app. Protect it with phishing-resistant MFA, conditional access and monitoring of risky sign-ins.
Good enough to move on: you can draw the OIDC authorization code flow with PKCE and name two checks a relying party must make on an ID token.
Key concepts
- IdP and relying party roles
- SAML 2.0 basics
- OAuth 2.0 roles and scopes
- OIDC and ID tokens
- Authorization code flow with PKCE
- redirect_uri and state pitfalls
- Consent phishing
Mini project
Register a test app with a free IdP developer tenant, implement login with OIDC and PKCE, and verify the ID token's signature, issuer, audience and expiry yourself.
Check yourself
Why is OAuth 2.0 alone not an authentication protocol, and what does OIDC add?
Free resources
- OAuth 2.0 (oauth.net)
- How OpenID Connect Works (OpenID Foundation)
- PortSwigger: OAuth authentication vulnerabilities (PortSwigger)