liveBook · Manning

Openid connect

As explained in Secure APIs

OpenID Connect is an identity layer on top of OAuth 2.0 that enables clients to verify an end user's identity and obtain basic profile claims.

OpenID Connect (OIDC) is an authentication protocol built on OAuth 2.0. It lets an application verify a user's identity through an external identity provider instead of managing authentication itself. section 7.6 section 7.8

OIDC separates the participants clearly: the OpenID Provider authenticates users, the relying party is the client application, and the user is the identity being verified. A successful flow returns an ID token and may also return an access token. section 7.6

A typical OIDC authorization-code flow works as follows:

  • Redirect the user to the provider with the client identifier and the openid scope. section 7.6
  • Let the user authenticate and consent to sharing identity information. section 7.6
  • Receive an authorization code, exchange it for tokens, and use the access token for API authorization. section 8.7
  • Validate access tokens on every request, including their claims and signature, before authorizing the operation. section 8.7

Adding OIDC to an API

A FastAPI service can integrate with Auth0 by registering an authorization-code client, redirecting users to Auth0, and validating the resulting JWT access tokens. The provider's discovery endpoint, /.well-known/openid-configuration, supplies integration metadata. Its JWKS endpoint supplies public keys; the token's kid header identifies the key used to validate the signature. Prefer a managed IDaaS provider or a standard self-hosted implementation such as Keycloak rather than building identity management from scratch. section 8.4 section 8.7

Figure 7.14 OIDC allows applications to use OPs to manage their user identities securely. In this case, the application redirects the user to the OIDC server to log in and give consent, and it obtains an ID token and an access token in return.
figure

Use the flow diagram to trace the redirect to the provider, user consent, and return of the ID token and optional access token. section 7.6

How Secure APIs covers it

How deep it goes
Explains participants, flow steps, discovery, JWKS validation, and implementation choices; stops short of covering every provider configuration.
Examples
Demonstrates Gmail or GitHub login, Auth0 with FastAPI, discovery metadata, authorization codes, JWTs, and JWKS keys.
What it assumes
Assumes basic authentication and authorization concepts while introducing identity providers, relying parties, tokens, and OIDC flows.
What you can do after
Implement OIDC authentication, integrate a provider, validate its tokens, and authorize API requests safely.
How it connects
Connects OAuth 2.0, authorization code flow, identity providers, JWTs, access tokens, JWKS, and role-based access control.

Also explained in

Compare how 13 books explain openid connect →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.