privileged.id

Protocols

OAuth, OpenID Connect and SAML compared

One is for authorization, two are for sign-in, and most organizations run all three. When to use which, and how they fit together.

Reviewed 6 min read 6 primary sources

OAuth 2.0, OpenID Connect and SAML 2.0 are often listed as alternatives. Only two of them are. OAuth is for authorization: letting a client call an API. OpenID Connect and SAML are both for federated authentication: letting an application sign a user in on the strength of an identity provider's login. Most organizations run all three at once, usually through the same identity provider.

Each in one line

OAuth 2.0
A framework for issuing access tokens that let a client call an API on a user's (or its own) behalf. RFC 6749 (2012), secured by RFC 9700 (2025). See OAuth 2.0.
OpenID Connect
An identity layer on OAuth: the client also receives a signed ID token saying who signed in, when and how. OpenID Foundation, Core 1.0 (2014, errata set 2 in 2023). See OpenID Connect.
SAML 2.0
An XML-based standard in which an identity provider sends a signed assertion through the browser to a service provider. OASIS (2005, with approved errata). See SAML 2.0.

Side by side

OAuth 2.0OpenID ConnectSAML 2.0
PurposeDelegated authorization to APIsAuthentication (sign-in) plus basic profile; also OAuth authorizationAuthentication (web SSO) and attribute exchange
Main artifactAccess token (format unspecified; often opaque or an RFC 9068 JWT); refresh tokenID token (signed JWT) plus OAuth tokensAssertion (XML) inside a Response
Audience of the artifactThe API (resource server)ID token: the client (aud = client_id)The SP (AudienceRestriction)
TransportBrowser redirect for the code; JSON over HTTPS back channel for tokens; Authorization header to APIsSame as OAuthBrowser redirect (DEFLATE + base64 in the URL) and auto-submitted HTML form POST (base64); optional back-channel artifact resolution
SigningNot required by RFC 6749; RFC 9068 JWT access tokens MUST be signedID tokens MUST be signed (JWS); optional JWE encryptionXML Signature (enveloped); with POST, every assertion must be covered by a signature on it or on the response
Key and metadata discoveryRFC 8414 /.well-known/oauth-authorization-server, jwks_uriOIDC Discovery /.well-known/openid-configuration, jwks_uriSAML metadata XML (entity ID, endpoints, certificates), exchanged out of band or fetched
User identifierNone defined (RFC 9068 sub for JWT access tokens)iss + subIdP entity ID + NameID (e.g. persistent)
Native mobile and SPA fitGood: code flow with PKCE, system browser (RFC 8252)Good: same flowsPoor: designed around browser form posts to a server-side SP; no standard API tokens
API accessYes, that is its jobYes, via the OAuth access tokenNot directly; an SP typically exchanges the login for its own session or tokens
LogoutNot defined; tokens can be revoked (RFC 7009)Separate specs: RP-Initiated, Front-Channel and Back-Channel Logout 1.0 (listed in OIDC Core §15.7)Single Logout profile (Profiles §4.4)
Main pitfallsUsing it for login; loose redirect URIs; bearer token leakageSkipping ID token validation; keying users on emailSignature wrapping; missing Audience/Recipient/InResponseTo checks; IdP-initiated replay

Logout deserves a caution in all three: each application has its own session, and "single" logout only works if every participant implements it and the messages actually reach them. Treat it as best effort, and keep application sessions reasonably short.

When to use which

  • A new web, mobile or single-page application needs users to sign in: OpenID Connect with the authorization code flow and PKCE. It works natively in mobile apps and SPAs, uses JSON and JWTs that every platform handles, and gives you an access token for your own API from the same flow.
  • An application needs to call an API on a user's behalf, or a service needs to call another service: OAuth 2.0 (authorization code + PKCE for users, client credentials for services). Add OpenID Connect only if the client also needs to know who the user is.
  • A SaaS product or enterprise application only offers SAML: use SAML for it. It is mature, well supported by enterprise identity providers, and there is no security reason to avoid it if the SP validates correctly.
  • You are building a product that enterprises will connect to their IdP: support OpenID Connect, and SAML as well if your customers ask for it; many enterprise IdPs are configured around SAML.
  • A device with no browser: the OAuth device authorization grant, with OIDC scopes if you need identity.

How they coexist in federation

One identity provider speaking three protocols Identity provider also the OAuth AS / OP Web or mobile app OIDC relying party SaaS application SAML service provider Your API OAuth resource server Partner directory upstream IdP OIDC: ID token SAML OAuth SAML or OIDC (inbound)
A typical estate: one identity provider acts as SAML IdP to older applications, OpenID Provider to new ones, and OAuth authorization server for APIs, and may itself federate to partners.

In practice the identity provider is the hub. The user signs in once at the IdP, with whatever authentication strength its policy requires, and the IdP issues whichever artifact each application understands: a SAML assertion for the SaaS app, an ID token for the new web app, an access token for the API that web app calls. The protocols differ, but the authentication event behind them is the same, so policy decisions (MFA, device posture, session length) belong at the IdP, not in each protocol.

Some patterns that follow:

  • Protocol translation. An IdP or federation proxy can accept SAML from an upstream partner IdP and issue OIDC to internal apps, or the reverse. NIST SP 800-63C-4 calls such components federation proxies ("sometimes referred to as brokers"). It notes that they can translate between federation protocols, that all subscriber information flows through them (so an attacker who compromises the proxy gets subscriber attributes and activity without targeting the IdP or RP), and that the FAL seen by the downstream RP is the lowest FAL along the whole path, which the proxy SHALL represent accurately (§3.3.3).
  • Same assurance rules for both assertion formats. SP 800-63C-4 treats the OIDC ID token and the SAML assertion as examples of the same thing, an assertion, and applies the same federation assurance levels to both. At every FAL the RP SHALL validate the assertion, the IdP SHALL sign it, and it SHALL be audience-restricted with replay protection. At FAL2 the assertion is restricted to a single RP and the transaction SHALL be initiated by the RP, which rules out IdP-initiated SAML at that level.
  • Account keys. Whatever the protocol, key federated accounts on the issuer plus its stable subject identifier: (iss, sub) in OIDC, (IdP entity ID, persistent NameID) in SAML. Never on email alone.
  • Tokens do not cross protocols by themselves. A SAML assertion is not an OAuth access token, and an ID token is not either. If an API must trust a login that happened via SAML, the IdP or a token service issues a proper access token for that API.

Federation assurance at a glance

From NIST SP 800-63C-4 Table 1, which applies equally to OIDC and SAML:

RequirementFAL1FAL2FAL3
Audience restrictionMultiple RPs allowed per assertion; single RP recommendedSingle RP per assertionSingle RP per assertion
Replay protectionRequired per RPRequiredRequired
Assertion injection protectionRecommendedRequired; transaction begins at the RPRequired; transaction begins at the RP
Trust agreementSubscriber-driven or pre-establishedPre-establishedPre-established
PresentationBearer assertionBearer assertionHolder-of-key assertion or bound authenticator

See assurance levels for how FAL relates to AAL and IAL.

Practical guidance

  • Default to OpenID Connect for new sign-in integrations and OAuth for API access; keep SAML for applications that need it.
  • Run all three from one identity provider so authentication policy is enforced in one place.
  • Prefer SP- or RP-initiated flows; they are required at FAL2 and above.
  • Validate artifacts fully: ID token validation, SAML response validation, access token validation.
  • Key accounts on issuer plus stable subject, never on email.
  • Do not use ID tokens or SAML assertions as API credentials; issue access tokens.
  • Inventory every federated application and its protocol, and review it alongside your access reviews.

Sources

  1. RFC 6749: The OAuth 2.0 Authorization Framework, IETF. IETF Trust Legal Provisions (brief quotations with attribution).
  2. OpenID Connect Core 1.0 incorporating errata set 2, OpenID Foundation. OpenID Foundation specification (cited, brief quotations).
  3. Profiles for the OASIS Security Assertion Markup Language (SAML) V2.0, OASIS. OASIS specification (cited, brief quotations).
  4. NIST SP 800-63C-4: Digital Identity Guidelines, Federation and Assertions, NIST. Public domain (U.S. government work).
  5. RFC 9700: Best Current Practice for OAuth 2.0 Security, IETF. IETF Trust Legal Provisions (brief quotations with attribution).
  6. SAML V2.0 Errata 05, OASIS. OASIS specification (cited, brief quotations).