← Back to section · Digital Security
OAuth 2.0 and OIDC: How an Authorisation Protocol Came to Double as an Identity Protocol
Behind every 'Sign in with Google' button, two protocols divide the labour: OAuth 2.0 handles authorisation, and OpenID Connect adds authentication on top. Why authorisation code flow plus PKCE became the default answer, and why ID tokens and access tokens must never be interchanged.
Start with a button
“Sign in with Google” is today’s most common authentication entry point. The user clicks, is sent to Google’s page to log in, returns, and the website knows who they are. Behind that chain, two protocols divide the labour: OAuth 2.0 (RFC 6749) and OpenID Connect (OIDC), built on top of it. Keeping their boundary straight is the prerequisite for understanding every security issue in this space.
OAuth 2.0 was created for authorisation, not authentication. The problem it solves is letting a third-party application obtain limited access to a user’s resources without ever receiving the user’s password — letting a photo-printing service read one album in your cloud drive, for instance. The protocol’s central artefact is the access token, which represents a permission, not an identity. Judging “who the current user is” from an OAuth access token alone is unsound by design: the token is issued to a particular application for a particular resource, and treating it as an identity card is like using a hotel key card to prove who you are — the card only proves its holder can open one room.
OIDC: the layer that adds identity
OpenID Connect adds one artefact to the OAuth 2.0 flow: the ID token. It is a signed JWT stating who the user is (the sub identifier), who issued the token (iss), which application it is for (aud), when it expires (exp), and a random value bound to this particular request (nonce). The application verifies the signature, checks iss and aud, and compares the nonce — only then is “authentication” complete. The division of labour becomes clean: OAuth handles authorisation and tokens; OIDC handles identity and login sessions. Today’s social logins and most enterprise single sign-on are, in substance, OIDC carrying the authentication part.
Flow selection is where the security weight sits. Historically, the implicit flow (tokens returned directly through browser URLs) and the password flow (the application collecting the user’s password itself) were both popular; current security best practice has explicitly retired both — the former exposes tokens in URLs, browser history and logs, and the latter trains users to hand passwords to third-party applications, the opposite of the protocol’s purpose. The standard answer now is authorisation code flow plus PKCE: the application sends the user to the authorisation server to log in and receive a one-time authorisation code, then the application’s backend (or the application itself) exchanges the code for tokens over a direct connection to the authorisation server, keeping credentials out of the browser front channel. PKCE (RFC 7636) adds one more binding: the application generates a random secret when initiating the request, first submitting its hash (code_challenge) and presenting the original (code_verifier) at exchange time — an intercepted authorisation code is worthless without the original. This is critical for mobile and single-page applications that cannot keep a client secret confidential, and it is now required for all client types.
Two pieces often skipped: consent and the provider-side session
Two links in this chain are commonly skipped in explanations, yet they decide the real shape of user experience and perceived security. The first is consent: during the authorisation flow the user is shown a page — “this application requests access to your albums and basic profile; allow?” — and it is not decoration. It is where OAuth makes the word “authorisation” concrete: permissions are itemised by scope, and the scope the user approves is the ceiling of the access token’s power. Its real-world effect depends on honesty at both ends: applications requesting only the scopes they need, and authorisation servers translating scopes into language humans can read. In practice, “select-all” permission requests combined with incomprehensible consent pages reduce the step to one more mindless click, but that is an ecosystem-governance problem; the granularity the protocol offers is sufficient.
The second is the session on the identity-provider side. After logging in at Google once, a user reaches any connected website “without a password” not because the websites share anything with each other, but because each website redirects the user to Google, and Google recognises from its own session cookie that “this person is already logged in”, skips the password prompt and issues an authorisation code directly. That is the actual mechanism of single sign-on: authenticate once, authorise many times. Its corollary matters just as much — logout is a distributed problem: clicking “sign out” on one website usually retires only that website’s local session, while the provider’s session persists, and the next click of a login button is waved straight through. This is not a bug but the inherent semantics of the federated model; understanding it is what allows correct design of step-up re-authentication for sensitive moments (such as forcing fresh verification before payment), instead of expecting one logout to clean the whole web.
Where the incidents actually happen
Real-world incidents with this protocol family rarely come from cryptography; they come from implementation details, and three frequent points are worth remembering. First, lax redirect_uri validation: if the authorisation server permits fuzzy matching of callback addresses, authorisation codes can be delivered to an attacker’s address and the trust root of the whole flow collapses — exact-match callback validation is a red line the RFCs stress repeatedly. Second, missing state and nonce: state defends against cross-site request forgery that binds an authorisation response to the wrong session, and nonce defends against ID-token replay; implementations that omit them have removed two cheap insurances. Third, token-use confusion: accepting an access token as an identity credential (without checking aud or signature), or using an ID token to call APIs. Every flavour of this confusion has real account-takeover incidents on record.
Finally, from this site’s vantage point: OIDC signatures today are mostly RS256 and ES256, still within Shor’s reach, but identity tokens are verified instantly and are short-lived, so their migration urgency ranks with the signature layer of passkeys — following the identity providers and the JOSE ecosystem is sufficient. For deployers, converging current flows onto authorisation code plus PKCE and tightening callback and parameter validation yields far more than early anxiety over token signatures. Ninety per cent of protocol security has always been in the usage, not the algorithm.
Tags: OAuth 2.0OpenID ConnectPKCEAuthentication