This guide is written by the team that builds Casdoor and describes the standards as published (listed under Sources), with notes on how Casdoor implements them as of November 7, 2026. Spotted a mistake? Tell us.
SAML 2.0 and OpenID Connect (OIDC) solve the same core problem: a user signs in once at an identity provider (IdP), and applications trust the IdP's statement about who they are. The difference is in how that statement is packaged and carried, and that decides where each one fits.
Short version: use OIDC for anything you build; support SAML because enterprise customers and SaaS tools will ask for it.
At a glance
| SAML 2.0 | OpenID Connect | |
|---|---|---|
| Published | 2005, OASIS | 2014, OpenID Foundation |
| Built on | XML, XML Signature | OAuth 2.0, JSON, JWT |
| Identity statement | Signed XML assertion | Signed JWT ID token |
| Transport | Browser POST or redirect between IdP and app | Browser redirect, then a back-channel call to the token endpoint |
| App is called | Service provider (SP) | Relying party (RP), or client |
| Configuration | Exchange XML metadata files and certificates | Client ID, client secret and a discovery URL (/.well-known/openid-configuration) |
| API access | Not part of SAML | OAuth 2.0 access tokens come with it |
| Mobile and SPA apps | Awkward | Designed for them (authorization code + PKCE) |
| Logout | Single Logout (SLO) profile | RP-initiated, front-channel and back-channel logout |
| Typical use | Workforce SSO into SaaS (Salesforce, AWS, Google Workspace) | Your own web and mobile apps, APIs, customer login |
How a SAML login works
- The user opens the app (the SP). It builds a signed or unsigned AuthnRequest and redirects the browser to the IdP.
- The user signs in at the IdP.
- The IdP returns an HTML form that auto-posts a SAML response to the SP's Assertion Consumer Service (ACS) URL. It contains an assertion signed with the IdP's certificate: the user's NameID, attributes (email, groups) and validity window.
- The SP checks the signature against the certificate from the IdP's metadata, checks audience and timestamps, and creates a session.
Everything goes through the browser. The SP never calls the IdP directly, which is why SAML works with apps that sit on networks the IdP can't reach.
How an OIDC login works
- The app redirects the browser to the IdP's authorization endpoint with its client ID, redirect URI, scopes (
openid profile email) and a PKCE challenge. - The user signs in and consents.
- The IdP redirects back with a short-lived authorization code.
- The app's backend exchanges the code at the token endpoint for an ID token (a JWT with the user's identity), an access token and optionally a refresh token.
- The app validates the ID token's signature using the IdP's published keys (JWKS), and can call the UserInfo endpoint or your APIs with the access token.
Because the tokens come over a direct back-channel call, nothing sensitive sits in the browser's history, and the same flow works for native and single-page apps with PKCE.
Which should you use?
Choose OIDC when:
- You're building the app, whether web, mobile, desktop or CLI.
- The app also needs to call APIs on the user's behalf.
- You want libraries in every language and a five-minute setup from a discovery URL.
- You're authorizing AI agents and MCP servers, which build on OAuth (more on that).
Choose SAML when:
- You're connecting to a SaaS product that only offers SAML SSO, or offers it on its enterprise plan.
- A customer's IT team requires it, which is common in B2B: "Does your app support SAML SSO?" is a standard procurement question.
- An existing app already speaks SAML and works.
In practice you need both. Your identity provider should be a SAML IdP for the SaaS tools your employees use and an OIDC provider for your own apps, and, if you sell B2B software, accept your customers' SAML or OIDC IdPs as upstream login providers.
Enterprise SSO: what buyers actually ask
If you sell software to businesses, the protocol question usually arrives as a procurement checklist rather than an architecture debate. The same six items come up in almost every enterprise review:
- "Do you support SAML 2.0?" Yes means your app can be the service provider for a customer's Entra ID, Okta, Ping or Google Workspace tenant.
- "Can each customer use their own IdP?" This is multi-tenant SSO: one app, many connections, each with its own metadata, certificate and attribute mapping. It is a product feature, not just a protocol.
- "Do you support SCIM?" SAML signs users in; SCIM creates, updates and deprovisions them. Buyers increasingly ask for both.
- "Does logout propagate?" SAML single logout and OIDC back-channel logout both exist, but browser cookie policies make true single logout hard. Be precise about what you support.
- "How do certificates rotate?" SAML connections break when an IdP certificate expires. Plan for overlapping certificates and metadata refresh before the first customer asks.
- "Do you support IdP-initiated login?" Some customers launch your app from their dashboard, which skips the SP-initiated flow. Support it if you can, and test the replay protections.
The practical takeaway: the protocol is the easy part; tenancy, provisioning and certificate lifecycle are the work. A broker such as Casdoor handles several of these for you: it accepts SAML or OIDC from each customer's IdP, exposes one OIDC connection to your app, and can sync users over SCIM.
Security notes
- SAML: most real-world vulnerabilities are in XML signature validation (signature wrapping, accepting unsigned assertions, comments in NameIDs). Use a well-maintained library and don't parse assertions yourself.
- OIDC: use the authorization code flow with PKCE, validate
iss,aud,expandnonce, and don't use the implicit flow for new apps.
One IdP for both
Casdoor is an open-source identity provider that is both a SAML 2.0 IdP (with metadata, signed assertions and single logout) and an OpenID Connect provider (discovery, JWKS, PKCE, refresh tokens, RP-initiated and back-channel logout), plus CAS, LDAP and RADIUS for older apps. It can also log users in through upstream SAML and OIDC providers such as Entra ID, Okta or Google Workspace.
See the SAML and SSO pages for details, self-host it for free, or run it on Casdoor Cloud from $6.67/month billed yearly. For the implementation details, read SAML SSO, the SAML IdP setup guide, SAML assertions, SAML metadata and SAML single logout; for the three-way comparison, see OAuth vs SAML vs OIDC.
FAQ
What is the difference between SAML and OIDC? SAML is an XML-based federation standard from 2005: the identity provider sends a signed assertion to the application. OIDC is a JSON and JWT layer on top of OAuth 2.0 from 2014: the application gets an ID token over a code flow. Both sign users in; OIDC also brings API access tokens and works better on mobile and single-page apps.
Is OIDC replacing SAML? For new applications, largely yes. SAML isn't going away soon, though: enterprise SaaS products and corporate IT still depend on it.
Is OIDC more secure than SAML? Neither is inherently more secure. OIDC is easier to implement correctly, because JSON and JWT validation have fewer pitfalls than XML signatures.
Do we need to support both SAML and OIDC? If you sell to enterprises, usually yes. Offer OIDC for the apps you build, and SAML for customers whose identity provider only speaks SAML. A broker such as Casdoor can accept either from the customer and give your app OIDC.
Is OIDC better than SAML? For new applications, usually yes: it is easier to implement correctly and works natively on mobile and single-page apps. SAML is not worse at signing users in; it is older and more XML-heavy. Support SAML where a customer requires it and use OIDC everywhere else.
Can an app support both? Yes. Many B2B apps let each customer choose SAML or OIDC for their SSO connection. Behind the scenes, a broker such as Casdoor can accept either and hand your app the same OIDC tokens.
What about OAuth 2.0? OAuth 2.0 is about authorization: giving an app an access token to call an API. OIDC adds an identity layer on top of OAuth 2.0 (the ID token and UserInfo), which is what makes it a login protocol.
Sources
- OASIS SAML 2.0 specifications
- OpenID Connect Core 1.0
- OpenID Connect Discovery 1.0
- RFC 7636: PKCE
- Casdoor docs: SAML
- Casdoor docs: Standard OIDC client
Product names are trademarks of their respective owners.