SAML vs OIDC
SAML 2.0SAML: Security Assertion Markup Language: an older XML-based standard for single sign-on, where the identity provider sends a signed assertion about the user. and OpenID ConnectOIDC: OpenID Connect: an identity layer on top of OAuth 2.0 that adds a signed ID token, so an application can learn who signed in at an identity provider, not just get access to an API. (OIDC) do the same job: they let people sign in to an app with the account your identity provider already holds, which is single sign-onSSO: Single sign-on: people sign in once with their organization's identity provider and reach many apps without a separate password for each.. They differ in how. SAML is an OASIS standard built on XML. The identity provider signs an XML assertion with XML Signature, and the browser carries it to the app in a form post. OIDC is "a simple identity layer on top of the OAuth 2.0 protocol". In the Authorization Code flow, the browser carries only a short code, and the app swaps it for an ID token, a signed JSON Web Token, over a direct HTTPS call. For a browser sign-in either one is fine, and many organisations have years of SAML set-up. For mobile apps, command-line tools and anything that also calls APIs, OIDC fits better. A self-hosted AI platform that has to fit into many organisations should offer both.Side by side
| SAML 2.0 | OpenID Connect | |
|---|---|---|
| Built on | Its own XML framework (OASIS) | OAuth 2.0 (OpenID Foundation) |
| What proves the sign-in | An XML assertion | An ID token, a JSON Web Token (JWT) |
| Signing | XML Signature; required on a response sent with the HTTP POST binding | JWS: "ID Tokens MUST be signed" |
| How it reaches the app | Usually through the browser: an auto-submitted form post to the app's callback | A code through the browser, then the token from a direct server-to-server request |
| Configuration | Metadata documents, or a pasted entity ID, URL and certificate | A discovery document at /.well-known/openid-configuration |
| Key rotation | A new certificate in each app, by hand or from refreshed metadata | The app re-reads the provider's published keys (jwks_uri) |
| Proof of the email | No standard "verified" flag; the app trusts the identity provider | email_verified claim |
| Proof of MFA | AuthnContextClassRef in the assertion | amr and acr claims in the ID token |
| Native, mobile and CLI apps | Awkward: Web Browser SSO assumes a browser; the Enhanced Client or Proxy (ECP) profile covers other clients, but your provider may not support it | Supported, with PKCE for public clients |
| Calling APIs afterwards | Not covered by browser SSO | OAuth 2.0 access tokens come from the same flow |
| Logout | A Single Logout protocol | Separate specifications, such as RP-Initiated Logout 1.0 |
How a SAML sign-in works
The SAML Technical Overview calls SAML a framework "for describing and exchanging security information between on-line business partners". It has four parts: assertions (statements about a user), protocols (request and response messages), bindings (how messages travel, such as HTTP Redirect, HTTP POST and HTTP Artifact) and profiles (combinations for one use case). The profile used for sign-in is Web Browser SSO.
In an app-initiated sign-in, the app redirects the browser to the identity provider with an authentication request. The person signs in there. The identity provider returns an HTML form that the browser posts to the app's callback. It holds a SAML response with the assertion, which names the user (the NameID) and carries attributes such as email and groups. The overview says that with the HTTP POST binding "it is mandated that the response message be digitally signed using XML Signature". The app checks that signature against the identity provider's certificate, which an admin has set up in advance.
SAML also allows identity-provider-initiated sign-in. The person clicks the app's tile in the provider's portal, and the provider posts an assertion nobody asked for. It is convenient. It also means the app cannot tie the response to a sign-in it started, which opens the door to login cross-site request forgery: an attacker's page posts the attacker's own valid assertion, and your browser ends up signed in to their account.
How an OIDC sign-in works
With the Authorization Code flow, the app redirects the browser to the identity provider with its client id, the scopes it wants (at least openid), a state value and a nonce. After sign-in, the provider redirects back with a short-lived code. The app sends that code, from its server, to the provider's token endpoint and receives the ID token. The core specification defines it as a JSON Web Token, signed with JWS.
The app then validates the token. The issuer must match exactly, the audience must contain the app's client id, the token must not be expired, and the nonce must equal the one the app sent. The signature is checked against keys the app fetches from the provider's jwks_uri, which Discovery 1.0 describes as containing "the signing key(s) the RP uses to validate signatures from the OP". When the provider rotates keys, the app picks up the new ones without anyone pasting a certificate.
For apps that cannot keep a secret, such as single-page apps, mobile apps and command-line tools, OIDC clients use OAuth's PKCE. RFC 7636 says public clients using the code grant "are susceptible to the authorization code interception attack" and defines Proof Key for Code Exchange to stop it. Because OIDC is OAuth 2.0 underneath, the same sign-in can also return an access token that lets the app call APIs on the user's behalf. SAML browser SSO has no equivalent.
Where each one goes wrong
Both are safe when implemented well. They fail in different places.
SAML's risks sit in XML. Signature checking must cover the assertion the app actually reads, not a different element elsewhere in the document. Each assertion should be accepted only once, so a captured response cannot be replayed. Use a maintained library rather than a hand-written XML parser. And there is no email_verified: the app trusts whatever email the identity provider asserts, so only connect a provider whose users cannot choose an arbitrary address.
OIDC's risks sit in token validation. Refuse unsigned tokens (alg: none). Refuse symmetric (HS*) algorithms too, unless you deliberately use the client secret as the HMAC key; otherwise an attacker may sign a token with the provider's public key as the secret. Check iss, aud, nonce and expiry on every token. Check state on every callback. Do not link an existing account by an email the provider has not verified; the specification says a true email_verified means "the OP took affirmative steps to ensure that this e-mail address was controlled by the End-User".
Both need the same policy decisions on top: who may sign in at all, how groups become roles, and whether the sign-in must include MFA. Those are covered in identity for AI platforms.
When to use which
- Your identity provider and your security team already run SAML for most apps: use SAML. Onboarding is a familiar form for them: entity ID, callback URL, certificate.
- You start fresh, or the provider supports both equally: prefer OIDC. Discovery and key rotation are automatic, and the tokens are JSON.
- Users sign in from a command-line tool, a desktop app or a mobile app: use OIDC with PKCE.
- The app also needs to call APIs as the user: use OIDC; the access token comes from the same flow.
- You need logout to reach every app at once: check what your provider actually implements. SAML defines Single Logout; for OIDC it is a separate specification. Either way, short app sessions are the reliable fallback.
How they combine
An app can offer both and let each organisation pick. A few rules keep that safe:
- One identity per protocol and issuer. Store an OIDC identity as issuer plus
suband a SAML identity as the provider's entity ID plusNameID. Asubis unique only within one issuer, and aNameIDonly within one SAML provider. - The same policy for both. Apply the same allow-lists, group mappings and MFA rule to each, so the choice of protocol does not change who gets in or what role they get.
- Neither provisions or removes accounts by itself. Both create accounts at sign-in at most. For removing leavers, see SSO vs SCIM.
In L2M
L2M, a self-hosted workflow builder and agent runtime, supports both, and both are off by default. With neither set, people sign in with email and password (Authentication and RBAC).
- OIDC (
OIDC_ENABLED=true) uses the Authorization Code flow with PKCE (S256),stateandnonce. The ID token must be signed with RS*, PS* or ES*;noneand HS* are refused outright.iss,aud,azp,exp,iatandnonceare checked. Discovery and the provider's keys are cached for an hour, and a token signed with an unknown key id refetches them, so key rotation needs no restart. An unverified email never links to an existing account unless you setOIDC_REQUIRE_EMAIL_VERIFIED=false(OIDC single sign-on). - SAML 2.0 (
SAML_ENABLED=true) needs the optional@node-saml/node-samlpackage, a 5.x release, added to the API; without it the SAML routes answer that SAML is not configured. The response arrives only by HTTP POST. Each assertion is accepted once, and withSAML_REQUIRE_IN_RESPONSE_TO=trueonly answers to a sign-in started from L2M in the same browser are accepted, which closes the login CSRF gap at the cost of portal sign-in. The configured provider is trusted for the email it asserts, because its certificate is pinned inSAML_IDP_CERT(SAML single sign-on). - Shared rules. Email-domain and group allow-lists, group-to-role mappings and the
SSO_MFAsetting work for both. MFA is read fromamroracrin the ID token, or from the assertion'sAuthnContextClassRef(MFA on SSO). - Logout ends the L2M session only, not the session at the identity provider.
LDAP sign-in against a directory is also available, as an API route.
Further reading
- SAML V2.0 Technical Overview (OASIS): assertions, bindings, profiles, Web Browser SSO
- OpenID Connect Core 1.0 (OpenID Foundation): ID token, flows,
email_verified - OpenID Connect Discovery 1.0 (OpenID Foundation): the configuration document and
jwks_uri - OpenID Connect RP-Initiated Logout 1.0 (OpenID Foundation)
- RFC 7636: Proof Key for Code Exchange (IETF)
- L2M docs: Authentication and RBAC