OpenID Connect
OpenID Connect (OIDC) is an identity layer on top of OAuth 2.0 that tells an application who a user is.
OAuth was designed for authorization. It hands an application an access token that says, in effect, "the bearer of this token may read this user's calendar." The token says nothing about who is holding it, which made early "log in with" buttons built on plain OAuth easy to get wrong. OpenID Connect fills the gap with an ID token, a signed JSON Web Token (JWT) in which the identity provider states who the user is, which application the token was issued to, and when it expires.
When you click "Sign in with Google" or "Sign in with Microsoft", the site is almost certainly using OpenID Connect. Before trusting an ID token, your application should:
- Check the token's digital signature against the provider's published keys.
- Confirm that the token was issued by the provider you expect (the
issclaim) and for your application (theaudclaim). - Reject expired tokens.
Better still, use a well-maintained OpenID Connect library, which makes all of these checks for you.