← Back to appsec.fyi

OAuth 2.0 vs SAML

One does authorization, the other does authentication. They overlap more than you'd think.

OAuth 2.0SAML 2.0
Primary purposeAuthorization (delegated access)Authentication (single sign-on)
Token formatJSON (JWT common)XML assertions
TransportHTTP redirects + REST APIsHTTP redirects + POST bindings
Best forAPIs, mobile apps, SPAsEnterprise SSO, web apps
ComplexitySimpler, more developer-friendlyComplex XML, signature validation
Mobile supportNative — designed for itAwkward — XML in mobile is painful
Attack surfaceToken theft, redirect URI manipulationXML signature wrapping, assertion replay

OAuth 2.0

OAuth 2.0 is an authorization framework — it lets a user grant an application limited access to their resources without sharing credentials. The access token says what the app can do, not who the user is. OpenID Connect (OIDC) adds an identity layer on top for authentication. Most modern APIs and mobile apps use OAuth/OIDC.

SAML

SAML 2.0 is an authentication protocol designed for enterprise single sign-on. The Identity Provider (IdP) sends a signed XML assertion to the Service Provider (SP) confirming the user's identity. It's battle-tested in enterprise environments but the XML-heavy design makes implementation error-prone — XML signature wrapping attacks have hit major providers.

Security considerations

OAuth attacks focus on redirect URI manipulation, token leakage, and CSRF in the authorization flow. SAML attacks target XML parsing — signature wrapping, assertion injection, and XXE in SAML processors. Both require careful implementation; the spec alone doesn't guarantee security.

Which to choose

For new applications, especially APIs and mobile: OAuth 2.0 + OIDC. For enterprise SSO where SAML is already established: SAML. Many organizations run both — SAML for internal SSO and OAuth for API access.

More comparisons: SSRF vs CSRF XSS vs CSRF XSS Types AuthN vs AuthZ IDOR vs BOLA SQLi vs NoSQLi SAST vs DAST Bounty vs Pentest SBOM vs SLSA Validation vs Encoding DAST vs IAST vs RASP SCA vs SAST Pentest vs Red Team WAF vs RASP