Learn how OpenID Connect enhances authentication by building on top of the OAuth 2.0 protocol to provide a secure, standard way to authenticate users.
Table of Contents
- What is OpenID Connect?
- How OIDC Works
- OIDC vs OAuth 2.0
- Benefits of OIDC
- ID Tokens Explained
- Implementing OIDC
- Security Considerations
- Troubleshooting
- Glossary
What is OpenID Connect?
OpenID Connect (OIDC) is an identity layer built on top of the OAuth 2.0 protocol. It allows clients (like Esadax) to verify the identity of users based on authentication performed by an authorization server.
- Developed by the OpenID Foundation.
- Widely adopted in modern web and mobile applications.
- Used by Google, Microsoft, Auth0, Okta, and more.
How OIDC Works
- User attempts login on the client application.
- Client redirects the user to the Identity Provider (IdP).
- User authenticates with the IdP (e.g., username + password, 2FA).
- IdP redirects back to the client with an ID token and (optionally) an access token.
- Client verifies the ID token’s signature and claims.
- User is authenticated and a session is created.
OIDC vs OAuth 2.0
| Feature |
OAuth 2.0 |
OpenID Connect (OIDC) |
| Purpose |
Authorization |
Authentication |
| Token Type |
Access Token |
ID Token + Access Token |
| User Identity |
Not guaranteed |
Explicitly provided |
| Profile Data Access |
Requires extra scopes |
Supported via openid scope |
| Standardized Claims |
No |
Yes |
✅ OIDC = OAuth 2.0 + identity + standardized user info.
Benefits of OIDC
- Interoperability: Standard across many providers and platforms.
- Security: Uses signed tokens and proven flows.
- Flexibility: Works for web apps, mobile apps, and APIs.
- Scalability: Ideal for distributed or multi-tenant systems.
- Federated Identity: One login works across many services.
ID Tokens Explained
An ID Token is a JWT (JSON Web Token) that contains information about the user.
- Common Claims:
sub: Subject (user ID)
email: User's email
name: Full name
iat: Issued at
exp: Expiry
iss: Issuer
aud: Audience (your app)
Example decoded ID token payload:
{
"sub": "1234567890",
"name": "Jane Doe",
"email": "jane@esadax.com",
"iat": 1692547200,
"exp": 1692550800,
"iss": "https://auth.provider.com",
"aud": "esadax-app"
}
Implementing OIDC
-
Choose a Provider: Google, Auth0, Okta, or self-hosted (e.g., Keycloak).
-
Register your Application: Obtain a client ID and client secret.
-
Redirect Users to the Provider:
- Include
response_type=code and scope=openid.
-
Handle Callback:
- Exchange the code for tokens using the provider’s
/token endpoint.
-
Verify ID Token:
- Check the signature,
aud, exp, and other claims.
-
Create Session:
- Use the token data to authenticate the user in your system.
Security Considerations
- Always validate ID tokens on the server side.
- Use HTTPS to avoid token interception.
- Set short token lifetimes and rotate secrets.
- Verify
nonce to prevent replay attacks.
- Use PKCE (Proof Key for Code Exchange) for public clients like SPAs and mobile apps.
Troubleshooting
Glossary
- OIDC: OpenID Connect, an identity layer on top of OAuth 2.0.
- OAuth 2.0: A protocol for authorizing access to resources.
- IdP: Identity Provider (e.g., Google, Okta) that authenticates the user.
- ID Token: A JWT that confirms the identity of the user.
- Access Token: A token used to access protected APIs.
- PKCE: Security extension to OAuth 2.0 for public clients.