Identity & Access Concepts

Identity and access management on the wire, from MFA and federation to OAuth, OIDC, directories and authorization models, explained in depth, one at a time.

Sort

Foundations

Authentication Factors

1

Passwords and Credential Attacks: Hashing, Stuffing, Spraying and Modern Policy

Server-side password security measured on one machine with Node 22 and openssl. Cost per hash of SHA-256, PBKDF2, bcrypt, scrypt and Argon2id at the current OWASP parameters and the guesses per second an attacker holding the leaked table gets (an estimate), unique salt versus precomputed tables and the pepper, the PHC string format and rehash-on-login migration, the attack classes (online and offline guessing, dictionary, credential stuffing, password spraying) against a local toy login endpoint, per-account and per-IP rate limits, progressive delay versus hard lockout and its denial of service, equal answers and equal time for unknown users with a dummy hash, detection across accounts, the NIST SP 800-63B-4 policy, breached-password screening with the k-anonymity range protocol (local sample, API docs only), a safe reset flow, and a table of attack, defense and metric.

2

MFA Factors: HOTP, TOTP, SMS, Push and Recovery

Authentication factors measured on the wire with Node 22 and openssl. Something you know, have and are, HOTP (RFC 4226) and TOTP (RFC 6238) written from scratch in 10 lines and checked against the 18 official RFC 6238 test vectors, the otpauth:// URI behind the QR code, clock drift and the tolerance window with the guess odds worked out, replay of a code, brute force and lockout, the secret encrypted at rest instead of hashed, single-use recovery codes, SMS and e-mail under NIST SP 800-63B-4, push fatigue and number matching, real-time phishing (AiTM) and origin binding, and a table of phishing resistance per factor.

3

WebAuthn, FIDO2 and Passkeys: The Protocol Measured

WebAuthn measured with no browser and no hardware, using a software ES256 authenticator and a 323-line Node 22 relying party: the registration ceremony (challenge, rp.id, user.id, authenticatorSelection), clientDataJSON and the CBOR attestationObject, authData decoded byte by byte (rpIdHash, UP/UV/BE/BS/AT/ED flags, signCount, AAGUID, credentialId, COSE key), the assertion signature over authData and the hash of clientDataJSON with step-by-step verification, discoverable credentials and login without a username, origin binding rejecting a phishing origin where a relayed TOTP code is accepted, signCount and clone detection, synced against device-bound passkeys, attestation formats and AAGUID, userVerification, the weak recovery link and a table of RP parameters.

4

Identity Threats: AiTM, Phishing, Consent Phishing and Recovery

Identity attacks as failures of the trust model, with defenses measured on toy services of my own. The phishing resistance ladder (NIST SP 800-63B-4, CISA), AiTM and why MFA that is not phishing-resistant does not protect the session cookie, a session that works from another client and stops working when bound to a device key, MFA fatigue and number matching, token theft and reuse detection, consent phishing in OAuth with the Entra consent policies and a Keycloak 26.8.2 grant viewed and revoked through the Admin API (and what happens to the refresh token), account recovery as the weak link measured before and after four controls, stuffing and spraying, privileged and service accounts, a 60-line detector with measured false positives, the compromised-account checklist, MITRE ATT&CK technique IDs and a table of threat, bypassed control, defense and signal.

Federation & SSO

1

SAML 2.0: Assertions, Bindings and SSO Flows

SAML 2.0 measured on the wire against a local Keycloak 26.8.2 acting as the IdP. SP-initiated with the Redirect and POST bindings versus IdP-initiated (no InResponseTo), the AuthnRequest and Response decoded from base64 and deflate, the Assertion annotated element by element (Issuer, NameID formats, Conditions, AudienceRestriction, SubjectConfirmationData, AuthnStatement, AttributeStatement), the SP and IdP metadata XML, the XMLDSig signature (C14N, Reference by ID, why checking the signature alone is not enough), the SP's mandatory checks each failed on purpose (signature, Destination/Recipient, Audience, time window, InResponseTo, replay, Issuer), the XML Signature Wrapping class demonstrated against a toy verifier and the fix of reading only the signed reference, attribute-to-role mapping, Single Logout and its limits, and SAML versus OIDC.

2

Session Management: Cookies, Fixation and Revocation

What happens after login, measured against a toy session server written for the lesson in Node 22 with no framework. A 128-bit session id against a counter, each Set-Cookie attribute (HttpOnly, Secure, Path, Domain, Max-Age, __Host- and __Secure- prefixes) with curl, session fixation and regenerating the id at login, idle against absolute expiry, remember-me with a selector and a hashed validator, CSRF with a synchronizer token, signed double submit and Sec-Fetch-Site, real logout, sign out everywhere, revocation on password change and SCIM active:false, a JWT as the session cookie under the same tests, the BFF pattern, a shared Redis store and what happens when it goes down, with SameSite and Entra Continuous Access Evaluation read from the docs only.

3

Choosing a Federation Protocol: SAML, OIDC, Kerberos and LDAP

Decision layer over the protocol lessons: a matrix of LDAP, Kerberos, SAML, OIDC and SCIM by client type, network, IdP ownership, logout, attributes, cost, attack surface and library maturity, then identity brokering measured with three Keycloak 26.8.2 containers on one Docker network. A hub realm that stores no passwords delegates to one upstream over OIDC and another over SAML, and the app sees a single OIDC token. Measured: the wire flow, claim mapping from both upstreams with identity provider mappers, kc_idp_hint, home realm discovery by e-mail domain with Keycloak organizations, the first broker login account takeover by unverified e-mail (six runs, which settings close it), and what hub logout does to the upstream sessions. B2B, B2C and CIAM, workforce, inter-organization federation, BFF gateways and SAML to OIDC migration are prose, with Entra docs only. Ends with a scenario, protocol, reason and pitfall table.

Directory Services

1

LDAP: Directories, DN, Schema and Binds

LDAP measured on the wire against a local OpenLDAP 2.6.10. The tree (DIT, DN, RDN), schema errors provoked on purpose (MUST/MAY, structural versus auxiliary, error 65), every operation, scopes and RFC 4515 filters, what an index is worth on 50,000 entries read from the server log (12.3 ms to 0.09 ms), anonymous, simple and SASL binds and the unauthenticated-bind bug, LDAPS versus StartTLS seen on the wire with a relay and openssl s_client, ACLs that hide entries and filter results, {SSHA} and {ARGON2} password hashes, paged results and referrals, the search-then-bind login, and LDAP injection against a local toy script with the RFC 4515 escape as the defense.

2

Active Directory and Entra ID: Domains, Forests and Hybrid

Active Directory measured against an AD-compatible Samba 4.22.11 domain (lab.test, two DCs) in Docker, and Entra ID and the hybrid pieces from the docs only. Forest, domain, domain controller, Global Catalog, sites and DNS SRV records, objects and the four names of a user (DN, sAMAccountName, UPN, objectGUID and objectSid decoded down to the RID), group types and scopes with AGDLP, memberOf against tokenGroups and the LDAP_MATCHING_RULE_IN_CHAIN filter, userAccountControl bits and bitwise filters, the two doors (LDAP with StartTLS or GSSAPI, Kerberos), multi-master replication, RID pools and FSMO with two DCs, GPO as a directory object plus SYSVOL, and the default password policy. Then Entra ID (tenant, app registration against enterprise application, delegated against application permissions, consent, Conditional Access, PIM, managed identities), hybrid sync (Entra Connect, Cloud Sync, the ms-DS-ConsistencyGuid source anchor), PHS against PTA against federation, Seamless SSO, hybrid join, the UPN friction, security in prose and a final AD against Entra table.

3

Kerberos: Tickets, TGT, Delegation and NTLM

Kerberos measured against a lab MIT KDC 1.21.3 in Docker. Realm, principals, kinit, the TGT and service tickets on the wire decoded with tshark, timestamp pre-authentication, what is inside a ticket (service key, authenticator, PAC), a keytab, Apache Negotiate and sshd GSSAPI validating for real, measured failures (Clock skew too great with a 5 minute window, expiry and renewal limits, an SPN built from an IP, a stale keytab kvno), encryption types, delegation (forwardable and unconstrained measured, constrained and RBCD in prose), trusts and Active Directory, golden ticket, silver ticket and Kerberoasting as failure classes with defenses, NTLM measured with a small verifier of our own (NT hash, challenge-response, relay), and a final table of ticket, who encrypts it, attack class and defense.

OAuth & OIDC

1

OAuth 2.0 from First Principles: Roles, Grants and Tokens

OAuth 2.0 measured on the wire against a local Keycloak 26.8.2 with only curl, jq and openssl. The four roles, public versus confidential clients, authorization code with PKCE S256 step by step, client credentials, device code (RFC 8628), refresh token rotation with reuse detection, what OAuth 2.1 removed (implicit, ROPC, wildcard redirects) and the attack behind each removal, scope versus audience, JWT (RFC 9068) versus opaque tokens, introspection (RFC 7662) and revocation (RFC 7009) timed, code reuse revoking the issued tokens, and invalid_grant, invalid_client and invalid_scope provoked on purpose.

2

OpenID Connect: ID Token, UserInfo, Discovery and Logout

OpenID Connect measured on the wire against a local Keycloak 26.8.2 with curl, jq and a 44-line Node 22 validator: what scope=openid adds, the ID token and the access token decoded side by side (aud is the client versus an API), the standard claims, discovery and JWKS, step-by-step ID token validation failing on a wrong nonce, wrong aud, tampered payload, alg none, expiry and at_hash, JWKS key rotation and caching, prompt, max_age and acr_values (and the silent acr downgrade), implicit and hybrid as history, and RP-initiated, front-channel and back-channel logout with what each one does not guarantee.

3

OAuth Token Exchange: Delegation and On-Behalf-Of

Why a service cannot forward the user's token, and the three real answers measured against Keycloak 26.8.2 with curl, jq and Node 22: the service's own credential, RFC 8693 token exchange as impersonation, and token exchange as delegation with may_act and a nested act claim. Covers audience restriction, the refusals (invalid_client, access_denied, invalid_scope, expired subject), resource silently ignored, widening scope by default and the downscope executor that stops it, why Keycloak stops at one delegation hop while an illustrative STS shows the A to B to C act chain, exchange cost versus a cache, audit, plus the Microsoft Entra on-behalf-of flow (docs only) and a comparison table.

4

OAuth Security: BCP, DPoP, mTLS, PAR, RAR and Resource Indicators

OAuth hardening measured on the wire against a local Keycloak 26.8.2 and a Node 22 resource server of your own: what RFC 9700 requires and what each rule stops, the iss mix-up defense (RFC 9207) checked by the client, DPoP (RFC 9449) with cnf.jkt and a stolen token refused for the Bearer scheme, a thief key, a replayed jti, htm, htu, ath and nonce, mTLS (RFC 8705) with cnf.x5t#S256 and a same-CA certificate refused, PAR (RFC 9126) taking the request out of the URL, JAR, RAR (RFC 9396) refused by Keycloak, resource indicators (RFC 8707) with per-API aud and invalid_target, FAPI 2.0, and what most apps actually need.

Authorization Models

Provisioning & Lifecycle

Workload Identity

1

Workload Identity: Service Accounts, mTLS and SPIFFE

Machine identity instead of static secrets, measured where it runs locally. A throwaway CA and mTLS with openssl, curl and a small Node server (what the server reads from the certificate SAN, refusals for a wrong CA, expiry and a missing certificate, authentication versus authorization, handshake cost), then SPIFFE/SPIRE 1.16.0 in Docker: SPIFFE IDs, X.509 and JWT SVIDs decoded and verified against the bundle, node and workload attestation with join_token and unix selectors, two workloads doing mTLS with an allow list of SPIFFE IDs, rotation at half life and the fact that revocation is the TTL. Docs only: Kubernetes projected ServiceAccount tokens, GitHub Actions OIDC federation (with the trust condition tested, including the loose repo:org/* mistake), Azure, AWS and GCP workload identity, service meshes. Ends with the anti-pattern of passing user tokens between services, rotation, audit and attribution, and a table of mechanism, what it proves, credential lifetime, who validates and the trap.

2

Privileged Access: Secrets, Vaults and Just-in-Time

Privileged access and secrets, measured on HashiCorp Vault 2.2.2 in dev mode in Docker with curl, jq and the vault CLI. The problem of standing privilege and blast radius, the four parts of PAM (inventory, vault with check-out and check-in, session recording, just-in-time access), then the operation: KV v2 versions and metadata, HCL policies and three path traps, tokens with TTL, renew, expiry (403 with invalid token), revoke trees and orphans, dynamic Postgres credentials (issued, expired at the lease, revoked, and an open session that survives revocation until pg_terminate_backend is added), static role rotation and rotate-root, AppRole with response wrapping against secret zero (a second unwrap is evidence of interception), a JIT elevation approved by a second person with a 20 second token, short-lived signed SSH certificates, seal and unseal, the audit device with HMAC masked values and audit-hash, and break-glass: the Entra emergency access guidance, the MFA and Conditional Access lockout lesson, a break-glass read that raises an alert, and generate-root. Docs only: Entra PIM, Azure Key Vault, AWS Secrets Manager, CyberArk, BeyondTrust, OpenBao, Vault Enterprise control groups. Ends with a comparison table of Key Vault, Secrets Manager, Kubernetes Secrets and Vault, the PAM suite against secrets manager market, the BSL licence note, and what NIST SP 800-53 asks.