01
Authentication Flows
Determining on the server who the request belongs to: setting up flows from the basic scheme to the session cookie, from the signed token to refresh exchange, from delegation and federation protocols to machine keys and the second factor, the observable consequence of getting the setup wrong, and the criteria for choosing among them.
- 01 Authentication and Authorization Distinction Showing that determining the principal behind a request and deciding what that principal can do are two separate questions: the observable consequence of a server that asks only the first one, the distinction between 401 and 403, and building the decision on deny by default.
- 02 Basic Authentication Building HTTP's own basic authentication scheme: the 401 challenge and the WWW-Authenticate header, showing that the carried value is a decodable encoding, constant-time comparison, and the consequences of the credential passing on every request.
- 03 Session-Based Authentication Building a server-held session record and carrying the session identifier with a cookie: verifying cookie attributes in the response header, measuring identifier renewal at login, logout taking immediate effect, and idle and absolute lifetime limits.
- 04 Token-Based Authentication Writing the principal into the signed value the request carries, and verification coming down to a local computation: the distinction between opaque and self-contained tokens, the bearer scheme, what the signature guarantees, and measuring that logout is not immediately effective.
- 05 JSON Web Tokens The signed token's standard format: the three-part compact serialization, what the registered claims mean, the steps a verifier must not skip, asking the configuration rather than the token for the algorithm, the clock skew allowance, and the signing key's length.
- 06 Refresh Tokens Separating the short-lived access token from the long-lived refresh token: storing the refresh token only as a hash, rotating it on every use, and measuring that presenting a used token again results in family revocation.
- 07 OAuth 2 Flows Building authorization delegation with four roles: the authorization code flow run end to end with an authorization server, a resource server, and a client; the rules of the PKCE verifier and the state parameter; the code's single use; and the client credentials and device flows.
- 08 OpenID Connect Adding an identity layer on top of the authorization delegation protocol: the ID token issued with the openid scope, its separation from the access token by audience, asymmetric signature verification through the discovery document and key set, and the nonce, issuer, audience, and duration steps.
- 09 Enterprise Federation Checking an identity carried by an assertion through signature, issuer, audience, and duration window; preventing reuse; mapping externally supplied attributes to a local role with an explicit table; and the limit of logout.
- 10 API Keys The entropy of the long-lived credential issued for machine callers, the operational value of the prefix and trailing characters, storing it as a hash, rotating it with a grace window, and limiting it with scope.
- 11 Multi-Factor Authentication The independence of factor classes, deriving the time-based code and the cost of the clock skew window, preventing the same code from being used a second time, and storing recovery codes as single-use.