Dev tools

SAML vs OIDC: Which Single Sign-On Protocol to Use

SAML vs OIDC compared: how each single sign-on protocol works, tokens, flows, security, mobile and API support, and which to build or offer first.

By OmniAI Editorial · Nov 23, 2026 · 11 min read

In SAML vs OIDC, both protocols do the same core job: they let a user sign in to an application with an account held by an identity provider (IdP) such as Okta, Microsoft Entra ID or Google, instead of a separate password for every app. That's single sign-on (SSO). The difference is age and design. SAML 2.0 is an XML-based standard from 2005, built for browser sign-in to enterprise web apps. OpenID Connect (OIDC), launched in 2014, is a thin identity layer on top of OAuth 2.0 that uses JSON tokens and works naturally for web, mobile and single-page apps.

The difference between OIDC and SAML matters most when you build the integration, less for the end user. For a new application, OIDC is usually the easier and more flexible choice. SAML remains essential in enterprise sales, because many corporate IT teams still connect apps to their IdP through SAML. This guide explains what each protocol is, how their login flows differ, compares tokens, security and tooling, and shows which to support first.

SAML vs OIDC at a Glance

SAML 2.0OpenID Connect (OIDC)
StandardisedOASIS Standard, approved March 2005OpenID Foundation, launched February 2014
Built onXML, XML SignatureOAuth 2.0, JSON, JSON Web Tokens
Identity tokenSigned XML assertionID token (a signed JWT)
Typical transportBrowser redirects and auto-submitted HTML forms (HTTP-POST)Browser redirects plus a back-channel token request
ConfigurationXML metadata exchanged between IdP and appDiscovery document at a well-known URL
Mobile and native appsAwkwardDesigned for them (authorisation code flow with PKCE)
API accessNot designed for itPairs with OAuth access tokens for APIs
Developer experienceVerbose XML; libraries essentialJSON; widely supported libraries
Where it dominatesEnterprise workforce SSO, older SaaS, education and governmentConsumer login, modern SaaS, mobile apps, new enterprise integrations

What Is SAML?

What is SAML? Security Assertion Markup Language is an open standard for exchanging authentication and attribute information between an identity provider and a service provider (SP), the application. SAML 2.0 was approved as an OASIS Standard on 1 March 2005 and has been the backbone of enterprise web SSO ever since.

The key object is the assertion: an XML document signed by the IdP that says, in effect, "this user authenticated at this time, and here are their attributes". Setup works by exchanging metadata: XML files that hold each side's entity ID, endpoint URLs and signing certificates.

A minimal assertion looks like this (shortened):

<saml:Assertion ID="_a75adf55" IssueInstant="2026-11-23T10:00:00Z">
  <saml:Issuer>https://idp.example.com</saml:Issuer>
  <ds:Signature>...</ds:Signature>
  <saml:Subject>
    <saml:NameID>[email protected]</saml:NameID>
  </saml:Subject>
  <saml:Conditions NotOnOrAfter="2026-11-23T10:05:00Z">
    <saml:AudienceRestriction><saml:Audience>https://app.example.com</saml:Audience></saml:AudienceRestriction>
  </saml:Conditions>
  <saml:AttributeStatement>
    <saml:Attribute Name="department"><saml:AttributeValue>Finance</saml:AttributeValue></saml:Attribute>
  </saml:AttributeStatement>
</saml:Assertion>

What Is OIDC?

What is OIDC? OpenID Connect is an identity layer built on top of OAuth 2.0, the authorisation framework used to grant apps access to APIs. OAuth on its own says what an app may access, not who the user is. OIDC adds that missing piece: an ID token, a signed JSON Web Token (JWT) carrying claims about the user and the login. The OpenID Foundation ratified the standard on 26 February 2014.

Configuration is simpler than SAML. An app needs the IdP's issuer URL, a client ID and usually a client secret. Everything else, such as endpoints and signing keys, comes from a discovery document at /.well-known/openid-configuration.

A decoded ID token payload looks like this:

{
  "iss": "https://idp.example.com",
  "sub": "248289761001",
  "aud": "my-app-client-id",
  "exp": 1795424400,
  "iat": 1795424100,
  "nonce": "n-0S6_WzA2Mj",
  "email": "[email protected]",
  "name": "Ana Lopez"
}

SAML vs OIDC Login Flows

Two rows of browser, identity provider and app; the top row has a curved path from browser to app, the bottom row an orange arrow straight from provider to app
SAML posts a signed XML assertion through the browser; OIDC sends a code through the browser and fetches tokens over a back channel.

Both start with the user trying to open the app and end with the app knowing who they are. The middle differs:

StepSAML (SP-initiated, HTTP-POST binding)OIDC (authorisation code flow)
1User opens the appUser opens the app
2App redirects the browser to the IdP with a SAML AuthnRequestApp redirects the browser to the IdP's authorise endpoint with client ID, redirect URI, scope=openid and a PKCE challenge
3User signs in at the IdP (password, MFA)User signs in at the IdP (password, MFA)
4IdP returns an HTML form that auto-posts the signed assertion to the app's Assertion Consumer Service URLIdP redirects back to the app with a short-lived authorisation code
5App validates the XML signature, audience, time limits and replayApp exchanges the code for tokens directly with the IdP (back channel), sending the PKCE verifier
6App creates a sessionApp validates the ID token signature and claims, then creates a session

The biggest practical difference is step 4. In SAML, the identity assertion travels through the user's browser. In OIDC's code flow, only a one-time code passes through the browser; the tokens come straight from the IdP to the app. That's one reason OIDC fits mobile apps, where there's no browser form to post.

SAML also supports IdP-initiated login, where a user clicks an app tile in their company portal and lands signed in. Enterprises like it; it's also harder to protect against forged or replayed logins, so many apps restrict or carefully validate it.

OIDC vs SAML for Enterprise SSO

On OIDC vs SAML for enterprise SSO: if you sell software to companies, customers' IT teams will ask "do you support SSO?" and usually mean their IdP (Okta, Entra ID, Google Workspace, Ping, OneLogin and others) connecting to your app.

ConsiderationSAMLOIDC
Customer IdP supportUniversal among enterprise IdPsSupported by all major IdPs
What customers ask forStill the most common request in enterprise security questionnairesIncreasingly accepted, especially by newer IT teams
Setup by the customerUpload or exchange metadata, map attributesCreate an app registration, share client ID and secret
Multi-tenant handling in your appOne SAML connection per customerOne OIDC connection per customer
Attribute mappingFlexible attribute statementsStandard claims plus custom claims
LogoutSingle logout defined, often unreliable in practiceFront-channel and back-channel logout specs; also unevenly supported

The practical answer for B2B SaaS: support both. Most identity platforms and SSO libraries let you offer SAML and OIDC connections per customer. If you must start with one for enterprise customers, start with SAML, since every corporate IdP speaks it; offer OIDC as soon as you can.

Alongside SSO, enterprise customers often ask for SCIM, a separate standard for automatically creating, updating and removing user accounts. SSO handles sign-in; SCIM handles the user lifecycle.

SAML vs OAuth

SAML vs OAuth is a common mix-up, because both appear in SSO discussions. They solve different problems:

  • SAML is about authentication: telling an app who the user is.
  • OAuth 2.0 is about authorisation: letting an app access an API on a user's behalf, with an access token, without sharing the user's password.
  • OIDC adds authentication on top of OAuth, which is why the real login comparison is SAML vs OIDC.

Our guide to authentication vs authorization explains the distinction, and OAuth vs JWT covers how OAuth and tokens relate.

SAML vs OIDC Security

A checklist with four ticked boxes and one empty box outlined in orange
Both protocols are safe when the token checks are done right; most incidents come from skipped checks.

Both protocols are secure when implemented correctly, and both have a history of implementation bugs.

RiskSAMLOIDC
Signature handlingXML signature wrapping attacks: a crafted document passes signature checks while the app reads an unsigned partAlgorithm confusion: accepting alg: none or the wrong key type
Token interceptionAssertion passes through the browserCode interception, mitigated by PKCE and exact redirect URI matching
ReplayMust check assertion ID, time limits and audienceMust check nonce, exp, aud and iss
Parsing complexityXML canonicalisation and namespaces are hard to get rightJSON is simpler to parse
Key rotationCertificates in metadata, often updated by handKeys published as a JWKS document and fetched automatically

Rules that apply to both:

  • Use a maintained library or identity service. Don't parse SAML XML or verify JWTs with hand-written code.
  • Validate everything: signature, issuer, audience, expiry and replay protection.
  • Pin each customer connection to the expected IdP and keys, so one tenant can't sign in as another.
  • Use HTTPS everywhere and exact redirect or ACS URLs.

Mobile Apps, SPAs and APIs

OIDC's advantage is clearest outside traditional web apps:

  • Mobile and desktop apps use the authorisation code flow with PKCE in the system browser, then receive tokens. SAML has no clean equivalent.
  • Single-page apps can use the same flow, or a backend-for-frontend that holds tokens server side.
  • APIs need access tokens. OIDC logins come with OAuth access tokens; SAML logins don't, so SAML-based apps need a separate mechanism for API calls. For machine-to-machine access, see our comparison of an API key vs OAuth.

Which Should You Use?

There's no single answer to which is better SAML or OIDC; it depends on who your users are and what their identity providers support.

SituationChooseWhy
New consumer or SaaS app with "Sign in with Google/Microsoft"OIDCNative to modern IdPs and social logins
Mobile or desktop appOIDCCode flow with PKCE is designed for it
Selling to large enterprisesSAML first, then OIDCEvery corporate IdP and IT team knows SAML
Internal tools at a company using Entra ID, Okta or GoogleEither; OIDC is usually simplerBoth are supported
App also needs API access tokensOIDCBuilt on OAuth
Legacy or government system that only speaks SAMLSAMLCompatibility

Adding SSO to Your App: A Checklist

  1. Decide where SSO lives. A managed identity service or an open-source identity server can handle both protocols for you; building on raw libraries means owning every protocol detail.
  2. Model tenants and connections. Each customer gets its own SAML or OIDC connection, tied to their email domains, so users are routed to the right IdP.
  3. Choose the user key. Store the IdP's issuer plus the stable subject identifier (SAML NameID, OIDC sub), not just an email address.
  4. Map attributes. Decide which claims set name, email, groups and roles, and what happens when they change.
  5. Plan provisioning and deprovisioning. Just-in-time creation at first login is a start; SCIM lets customers remove access centrally.
  6. Handle certificate and key rotation without downtime: OIDC fetches keys automatically; SAML usually needs a second certificate slot.
  7. Test with real IdPs. Okta, Entra ID and Google each have quirks; most offer free developer tenants.

Common Mistakes

  • Treating OAuth access tokens as proof of identity. Use the OIDC ID token, or the userinfo endpoint, to identify the user.
  • Skipping assertion or token validation because the request came from the IdP's domain.
  • Accepting IdP-initiated SAML without safeguards.
  • Hard-coding certificates or keys and breaking when the IdP rotates them.
  • Matching users by email alone across tenants, which can let someone with the same address at another IdP take over an account. Match on the IdP plus its stable subject identifier.

FAQ

Is OIDC replacing SAML?

For new apps and consumer logins, largely yes. In enterprise workforce SSO, SAML is still widely used and will be for years, so B2B apps usually support both.

Is OIDC more secure than SAML?

Neither is inherently more secure. OIDC's JSON tokens and code flow avoid some of SAML's XML parsing pitfalls, but both are safe only when validated correctly.

Can SAML and OIDC be used together?

Yes. Many identity providers accept a SAML login from one system and issue OIDC tokens to another, acting as a bridge.

Does OIDC use JWT?

Yes. The ID token is a JSON Web Token, signed by the identity provider. Access tokens may also be JWTs, but that depends on the provider.

What does an app need to set up SAML or OIDC?

For SAML: the IdP's metadata (entity ID, SSO URL, signing certificate) and your app's metadata. For OIDC: the issuer URL, a client ID and secret, and a redirect URI.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog