Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Architecture Leadership
Lesson 17 of 32

Identity: authentication, authorisation and SSO

How OAuth 2.0, OpenID Connect, SAML and session design fit together, and how to centralise identity safely.

18 min read

Authentication versus authorisation

Authentication answers 'who are you?'; authorisation answers 'what may you do?'. Mixing them causes most identity bugs. Centralise authentication in one identity service or provider so password hashing, MFA, lockout and account recovery are done once and done well. Authorisation usually stays closer to the data, because only the owning service knows that user 42 may edit document 7. Store passwords only as slow, salted hashes (Argon2id or bcrypt with a cost that takes around 100 ms), never reversibly encrypted.

OAuth 2.0 and OpenID Connect

OAuth 2.0 is a delegation protocol: it lets a client obtain an access token to call an API on a user's behalf. It says nothing about who the user is. OpenID Connect (OIDC) adds an identity layer on top: an ID token (a signed JWT) describing the authenticated user. For browser and mobile apps use the authorisation code flow with PKCE; the implicit flow and resource owner password flow are deprecated in OAuth 2.1.

  • Access tokens: short-lived (5-15 minutes), scoped, sent to APIs
  • Refresh tokens: longer-lived, stored securely, rotated on every use
  • ID tokens: for the client to learn who logged in, not for calling APIs
  • Validate signature, issuer, audience and expiry on every JWT

Single sign-on

SSO lets a user authenticate once with an identity provider (IdP) such as Okta, Entra ID or Google Workspace and access many applications. Enterprise customers expect SAML 2.0 and increasingly OIDC; both work by having the application trust signed assertions from the IdP. Add SCIM for provisioning, so that when HR deactivates an employee, their accounts across all apps are disabled within minutes rather than lingering for months. Plan for IdP outages too: decide whether existing sessions stay valid and whether a break-glass admin login exists.

Sessions and revocation

Stateless JWTs are fast to verify but hard to revoke before they expire. The common compromise is short-lived access tokens plus a server-side session or refresh token that can be revoked instantly; a stolen access token is then useful for minutes, not days. For high-risk actions (changing payout details, exporting data) require step-up authentication with a fresh MFA challenge. Rate limit login attempts per account and per IP, and alert on credential-stuffing patterns such as many accounts failing from one network.

Authorisation models

Role-based access control (RBAC) maps users to roles and roles to permissions; simple and auditable, but roles multiply. Attribute-based (ABAC) evaluates policies on attributes such as department, region or data classification. Relationship-based (ReBAC), as in Google's Zanzibar paper and tools like OpenFGA, models permissions as a graph ('user is editor of folder which contains document'), fitting sharing-heavy products. Many organisations centralise policy definitions with a policy engine such as OPA while enforcing decisions in each service. Whatever the model, deny by default and log every denied request.

Key takeaways

  • Centralise authentication; keep authorisation decisions close to the data owner.
  • OAuth delegates API access; OIDC adds identity. Use the code flow with PKCE.
  • Pair short-lived access tokens with revocable sessions or refresh tokens, and step-up MFA for risky actions.
  • Choose RBAC, ABAC or ReBAC by how permissions are shaped in your product.

Sign in to track lessons and earn badges.

Security architecture: threat modelling and zero trustSecrets and key management

Challenge checkpoint

Course: 0/32 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 3/10Design a Login ServiceApply authentication fundamentals: hashed credentials, short-lived tokens, revocation and rate limits on login.Easy
All 10 challenges →