The Protocol Decision That Shapes Your Identity Architecture
Choosing a federation protocol is not a trivial configuration toggle—it is an architectural decision that ripples through your security posture, developer experience, and long-term maintainability. SAML and OpenID Connect (OIDC) are the two dominant standards for federated authentication, but they come from different eras, target different use cases, and impose fundamentally different integration patterns.
This guide breaks down the real engineering differences, walks through the flows side by side, and gives you a practical framework for choosing—or combining—these protocols.
A Brief History: Why Two Standards?
SAML 2.0 was ratified in 2005 by OASIS. It was built for a world of enterprise portals, on-premise identity providers, and XML-centric web services. Its design reflects that era: verbose XML assertions, complex canonicalization for signatures, and a metadata-driven trust model that works well for static, pre-configured relationships. OpenID Connect 1.0 was finalized in 2014 on top of OAuth 2.0. It was designed for a mobile-first, API-driven world. It uses JSON, JWTs, and RESTful endpoints. It inherits OAuth's delegation model and adds an identity layer on top.Understanding this history matters because each protocol carries the assumptions of its era into your architecture.
Protocol Flows: Side by Side
The following diagram shows how a user authenticates via SAML (left) versus OIDC (right). While both achieve the same goal—federated SSO—the mechanics differ significantly.
Key Differences in the Flows
- Token delivery: SAML posts the full assertion through the browser (front-channel). OIDC uses a back-channel token exchange—the browser only ever sees a short-lived authorization code, never the tokens themselves. This gives OIDC a security advantage for token confidentiality.
- Token format: SAML uses XML with XML Digital Signatures (XMLDSig). OIDC uses compact JWTs signed with JWS. The practical difference is enormous: XML canonicalization bugs have been the source of critical SAML vulnerabilities, while JWT validation is comparatively straightforward.
- Discovery: OIDC has a standardized discovery endpoint (
/.well-known/openid-configuration) that returns all endpoints and supported features as JSON. SAML uses XML metadata documents that must be exchanged out-of-band or via a metadata URL.
Feature Comparison Matrix
XML vs JSON: More Than Syntax
The data format difference is not cosmetic—it drives real security and developer-experience consequences.
SAML's XML Complexity
SAML assertions use XML namespaces, canonicalization (C14N), and enveloped signatures. A single assertion can easily be 2-4 KB of XML. Signature validation requires:
- Extracting the
SignedInfoelement - Canonicalizing it (exclusive C14N)
- Verifying the digest of the referenced elements
- Verifying the signature over the canonicalized
SignedInfo
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="_abc123" IssueInstant="2026-02-15T10:00:00Z" Version="2.0">
<saml:Issuer>https://idp.example.com</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<!-- XMLDSig signature block -->
</ds:Signature>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
user@example.com
</saml:NameID>
</saml:Subject>
<saml:Conditions NotBefore="2026-02-15T09:55:00Z" NotOnOrAfter="2026-02-15T10:05:00Z">
<saml:AudienceRestriction>
<saml:Audience>https://sp.example.com</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2026-02-15T10:00:00Z">
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute Name="email">
<saml:AttributeValue>user@example.com</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
OIDC's JWT Simplicity
An OIDC ID token is a compact JWT—three Base64URL-encoded segments separated by dots. Validation is straightforward: decode the header, fetch the signing key from the JWKS endpoint, verify the signature, check claims (iss, aud, exp, nonce).
{
"iss": "https://idp.example.com",
"sub": "user-123",
"aud": "client-app-456",
"exp": 1739620800,
"iat": 1739617200,
"nonce": "abc123xyz",
"email": "user@example.com",
"email_verified": true,
"name": "Jane Doe"
}
The attack surface is smaller, the validation logic is simpler, and the token is compact enough to fit in an HTTP header—critical for API-driven architectures.
Use Case Analysis
When SAML Is the Right Choice
- Enterprise SSO with legacy IdPs: If your organization runs Active Directory Federation Services (AD FS), or integrates with partners who only support SAML, you will need SAML. Many large enterprises have invested heavily in SAML infrastructure.
- Regulated industries with established SAML trust: Healthcare (via NIST frameworks), government, and financial services often have pre-existing SAML trust federations that would be costly to migrate.
- Rich attribute statements: SAML's
AttributeStatementcan carry complex, typed attributes with multi-valued entries. While OIDC claims can also carry custom data, SAML's attribute model is more formally specified for enterprise attribute exchange.
When OIDC Is the Right Choice
- Consumer-facing applications: CIAM scenarios—social login, progressive profiling, mobile apps—are OIDC's sweet spot. Every major social identity provider (Google, Apple, Microsoft) offers OIDC.
- API authorization: Because OIDC sits atop OAuth 2.0, you get access tokens for API security out of the box. SAML was never designed to authorize API calls.
- Mobile and single-page applications: OIDC supports the Authorization Code Flow with PKCE, which is specifically designed for public clients (mobile apps, SPAs). SAML's browser POST binding is fundamentally incompatible with native mobile flows.
- Microservices architectures: JWT-based tokens can be validated locally by each service without calling back to the IdP, enabling stateless authentication across a distributed system.
The Hybrid Approach
Many organizations run both protocols simultaneously. A common pattern:
- SAML for workforce SSO: Employees authenticate via SAML to internal enterprise applications through Active Directory or a workforce IdP.
- OIDC for customer-facing apps and APIs: Customer-facing web and mobile applications use OIDC for authentication and OAuth 2.0 for API authorization.
- The IdP bridges both worlds: Modern identity platforms (Okta, Azure AD, Keycloak) can act as both a SAML IdP and an OIDC Provider simultaneously, even for the same user population.
Migration Strategies: SAML to OIDC
If you are planning a migration from SAML to OIDC, consider these approaches:
Parallel Run with Gradual Cutover
- Configure your IdP to support both SAML and OIDC for the same applications
- Update applications one at a time from SAML SP to OIDC RP
- Validate session behavior, attribute mapping, and logout flows
- Decommission SAML endpoints only after full validation
Protocol Translation Gateway
For applications that cannot be modified (legacy COTS software), deploy a protocol translation gateway:
- The gateway acts as a SAML Service Provider to the legacy application
- The gateway acts as an OIDC Relying Party to your modern IdP
- It translates SAML assertions to OIDC tokens (and vice versa) transparently
Legacy App (SAML SP) → Gateway → OIDC Provider
This pattern is well-supported by products like Keycloak (see Keycloak IAM for Modern Applications) and can serve as a long-term bridge.
Claims Mapping Considerations
The trickiest part of migration is typically attribute/claims mapping:
| SAML Attribute | OIDC Claim | Notes |
|---|---|---|
NameID | sub | May need format conversion |
email attribute | email | Usually straightforward |
groups attribute | groups (custom) | No standard OIDC groups claim |
AuthnContextClassRef | acr | Authentication context |
SessionIndex | sid | Session identifier |
Security Considerations
Both protocols have mature security models, but the threat landscape differs:
SAML-Specific Risks
- XML Signature Wrapping (XSW): Ensure your SAML library validates that the signed element is the one being processed
- XXE (XML External Entity): Disable external entity processing in your XML parser
- Replay attacks: Validate
InResponseTo,NotBefore,NotOnOrAfter, and maintain an assertion ID cache
OIDC-Specific Risks
- Token leakage: Always use the Authorization Code flow with PKCE—never the Implicit flow
- JWT algorithm confusion: Validate the
algheader against an allowlist; never acceptnone - Insufficient audience validation: Always check the
audclaim matches your client ID
Decision Framework
Ask these questions to determine your protocol choice:
- Who are your users? Workforce → SAML is safe. Consumers → OIDC. Both → hybrid.
- What are you protecting? Web apps only → either works. APIs → OIDC. Mobile → OIDC.
- What does your IdP support? If your IdP only does SAML, start there and plan migration.
- What do your partners require? B2B federation often means SAML. Check partner requirements early.
- What is your team's expertise? OIDC has a gentler learning curve and better modern tooling.
Conclusion
SAML and OIDC are not competitors—they are tools for different contexts. SAML excels in structured enterprise federations with established trust relationships. OIDC excels in dynamic, API-driven, consumer-facing environments. The best identity architectures use both where appropriate, connected through a capable identity provider that bridges the two worlds.
The key is to avoid the trap of choosing based on familiarity alone. Evaluate your actual requirements—user types, application architectures, partner ecosystems, and team capabilities—and let those drive the decision.