← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

OpenID Connect (OIDC)

Networking PHP 7.0+ Intermediate
debt(d7/e5/b5/t7)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The detection_hints indicate automated detection is 'no' and the tool listed (semgrep) would require custom rules to catch patterns like using access tokens for identity or skipping ID token validation. These misuses are silent in normal operation — a user appears to log in successfully even when auth is done incorrectly — and won't surface until a security review or penetration test.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix points to switching from OAuth2 access-token-based identity to OIDC ID token parsing, but the common_mistakes reveal multiple layered issues: token signature validation, audience claim checking, nonce verification. Correcting all of these touches auth middleware, session handling, and token validation logic across a component — more than a single-line fix but typically contained within the auth subsystem.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). Applies to web and API contexts broadly (applies_to: web, api). An incorrectly implemented auth flow shapes every feature that depends on knowing who the user is — session management, access control, user data retrieval. However, it is typically encapsulated in an auth layer rather than diffused across the entire codebase, so it doesn't reach b7.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap (contradicts how a similar concept works elsewhere)' (t7). The misconception field states explicitly that OAuth 2.0 and OIDC are conflated — OAuth 2.0 access tokens are widely used for API authorization, so developers familiar with OAuth naturally (but incorrectly) use access tokens for identity. The 'obvious' pattern from OAuth experience leads directly to an insecure implementation. Multiple compounding mistakes (no signature validation, no aud check, no nonce) make this a serious trap just short of catastrophic.

About DEBT scoring →

Also Known As

OIDC OpenID SSO identity provider

TL;DR

An identity layer on top of OAuth 2.0 — while OAuth 2.0 handles authorisation (access to resources), OIDC adds authentication (who the user is) via the ID token.

Explanation

OpenID Connect adds to OAuth 2.0: an ID token (JWT containing user identity claims — sub, name, email, picture), a UserInfo endpoint (fetch additional claims), and a discovery document (/.well-known/openid-configuration lists all endpoints). The ID token is for the client application (to know who logged in); the access token is for calling APIs. Flow: same as OAuth 2.0 authorization_code flow but with openid scope added. PHP libraries: league/oauth2-client, thephpleague/oauth2-google, lcobucci/jwt for token validation.

Common Misconception

OAuth 2.0 and OpenID Connect are the same — OAuth 2.0 is an authorisation framework (access tokens for APIs); OIDC adds authentication (identity tokens telling you who the user is). Using OAuth alone doesn't tell you who is logged in.

Why It Matters

Many PHP apps implement 'Login with Google' using OAuth 2.0 access tokens to identify users — this is insecure; the access token is opaque and not guaranteed to identify who is logged in. OIDC's ID token is the correct mechanism.

Common Mistakes

  • Using the OAuth access token to identify the user — access tokens are for calling APIs, not authentication.
  • Not validating the ID token signature — anyone can craft a JWT without signature validation.
  • Not checking the aud (audience) claim — ID tokens from other clients can be replayed.
  • Not verifying the nonce — prevents ID token replay attacks.

Code Examples

✗ Vulnerable
// Using access token for identity — wrong:
$accessToken = $oauth->getAccessToken('authorization_code', ['code' => $_GET['code']]);
// Access token is opaque — you don't know who this user is from the token alone
$user = $googleApi->getUser($accessToken->getToken()); // Extra API call needed
// Token may belong to any Google user
✓ Fixed
// OIDC — ID token contains verified identity:
$provider = new Google(['clientId' => ..., 'redirectUri' => ...]);
$tokens = $provider->getAccessToken('authorization_code', [
    'code' => $_GET['code'],
    'scope' => 'openid email profile',
]);

// ID token: JWT with signed identity claims
$idToken = $tokens->getValues()['id_token'];
$claims  = $jwtValidator->validate($idToken, [
    'iss' => 'https://accounts.google.com',
    'aud' => CLIENT_ID,
    'nonce' => $_SESSION['oauth_nonce'],
]);
$userId = $claims['sub']; // Stable user identifier

Added 16 Mar 2026
Edited 22 Mar 2026
Views 49
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 1 ping W 0 pings T 4 pings F 0 pings S 3 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 1 ping T 0 pings W 0 pings T 0 pings F 0 pings S 2 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 7 Scrapy 7 Perplexity 6 Ahrefs 4 SEMrush 4 Google 3 Bing 2 ChatGPT 2 Claude 1 Meta AI 1 PetalBot 1
crawler 35 crawler_json 3
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: High
⚡ Quick Fix
Use OpenID Connect (OIDC) when you need identity — it adds an ID token to OAuth2; parse the ID token claims for user identity rather than calling the userinfo endpoint on every request
📦 Applies To
PHP 7.0+ web api
🔗 Prerequisites
🔍 Detection Hints
Using OAuth2 access token to identify users; no ID token parsing; calling userinfo endpoint on every request instead of caching claims
Auto-detectable: ✗ No semgrep
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: High Context: File Tests: Update
CWE-287


✓ schema.org compliant