Menu
Course/Security & Identity Patterns/Federated Identity Pattern

Federated Identity Pattern

Delegate authentication to external identity providers: SAML, OIDC, SSO flows, identity federation across organizational boundaries.

12 min read

What Is Federated Identity?

Federated identity is an architectural pattern in which a system delegates authentication to a trusted external party — an Identity Provider (IdP) — rather than managing credentials itself. The application, called the Service Provider (SP) or Relying Party (RP), trusts the IdP to assert who the user is, freeing the application from storing passwords, handling MFA, or enforcing password policies.

This pattern is the backbone of Single Sign-On (SSO): a user authenticates once with the IdP and is granted access to multiple service providers without re-entering credentials. Common real-world IdPs include Auth0, Okta, Azure Active Directory (Azure AD / Entra ID), Google Identity, and AWS Cognito.

Core Protocols

ProtocolFormatTypical Use CaseToken Type
SAML 2.0XML assertionsEnterprise SSO, B2B federationXML Assertion
OpenID Connect (OIDC)JSON/JWTConsumer & cloud-native appsID Token (JWT)
OAuth 2.0JSONDelegated authorization (not identity)Access Token
WS-FederationXMLMicrosoft ecosystems, legacy enterpriseXML Token
ℹ️

OIDC vs OAuth 2.0

OAuth 2.0 answers 'what can this app do on your behalf?' — it is an authorization framework. OpenID Connect is a thin identity layer on top of OAuth 2.0 that answers 'who are you?' — it is an authentication protocol. In most modern systems, you use OIDC for login and OAuth 2.0 access tokens for API authorization.

The OIDC / SSO Flow

Loading diagram...
OIDC Authorization Code flow with PKCE — the recommended flow for web and mobile apps.

Cross-Organizational Federation

When two organizations need to share access — for example, a company allowing its enterprise customer's employees to log in — they establish a trust relationship between IdPs. This is called identity federation or B2B federation. The typical flow is:

  1. Organization A (customer) has their own IdP (e.g., Azure AD).
  2. Organization B (SaaS vendor) configures its IdP (e.g., Okta) to trust Organization A's IdP as an external identity source.
  3. When a user from Organization A accesses Organization B's app, they are redirected to their own IdP for authentication.
  4. Organization A's IdP issues a SAML assertion or OIDC token to Organization B's IdP, which maps it to a local user account.
  5. Organization B's IdP issues a token to the application.

Architecture Diagram

Loading diagram...
Cross-organizational SAML/OIDC federation — the SaaS app trusts Okta, Okta trusts Azure AD.

Key Design Decisions

DecisionOptionsRecommendation
Protocol choiceSAML vs OIDCPrefer OIDC for new builds; support SAML for enterprise customers who require it
Session managementIdP-managed vs SP-managed sessionsSP manages short sessions; IdP handles revocation via backchannel logout
Just-in-time provisioningPre-provisioned vs JITJIT provisioning on first login reduces admin overhead for large enterprises
Attribute mappingStatic vs dynamic claim mappingMap IdP claims to local roles dynamically via claim transformation rules
Token storageCookie vs localStorageHttpOnly, Secure, SameSite=Lax cookies — never localStorage for sensitive tokens
⚠️

Security Warning: Validate Every Token

Never trust an ID token without validating its signature (using the IdP's public JWKS), issuer (`iss` claim), audience (`aud` claim), and expiry (`exp` claim). Skipping any of these validations opens your system to token substitution attacks.

💡

Interview Tip

When asked about SSO or federated identity in an interview, walk through the OIDC Authorization Code flow step by step. Interviewers want to see that you understand the back-channel token exchange (why the code is exchanged server-side rather than returning tokens directly to the browser) and that you know the difference between authentication (OIDC) and authorization (OAuth 2.0 scopes). Mention PKCE for public clients.

📝

Knowledge Check

5 questions

Test your understanding of this lesson. Score 70% or higher to complete.

Ask about this lesson

Ask anything about Federated Identity Pattern