What is SAML and How SAML Authentication Work?

Andy AgarwalAndy Agarwal
5 min read

What Is SAML?

Security Assertion Markup Language (SAML) is an XML-based open standard that enables secure, federated Single Sign-On (SSO) across independent applications, domains, and even organizations.
Instead of prompting users to authenticate separately to every service, SAML lets them sign in once with an Identity Provider (IdP) and then access any trusted Service Provider (SP) without re-entering credentials. The IdP issues digitally-signed SAML assertions that the SP consumes to establish the user’s identity and privileges.

The standard is governed by OASIS (Organization for the Advancement of Structured Information Standards) and is currently at version 2.0 (approved in 2005). It remains the de-facto protocol for enterprise SSO, government portals, and many cloud SaaS ecosystems.

Key Benefits

Benefit

Why It Matters

Strong security

Assertions are signed and optionally encrypted; mutual metadata exchange establishes trust, mitigating credential-phishing and replay attacks.

True SSO

Users authenticate once and seamlessly access any participating application—reducing password fatigue and help-desk resets.

Scalability & flexibility

Supports complex federation topologies (one-to-many, many-to-one, hub-and-spoke) and multiple auth methods (MFA, smart cards, biometrics).

Interoperability

A well-defined XML schema and binding profiles allow products from different vendors to work together with minimal customization.

Cost savings

Fewer password resets, streamlined onboarding/off-boarding, and centralized policy enforcement lower IT overhead.

Regulatory compliance

Meets stringent enterprise and government security requirements (FIPS 140-2, FedRAMP, ISO 27001, GDPR, etc.).

Improved UX

Consistent login experience boosts productivity and reduces friction, especially for distributed workforces.

Core Terminology

Term

Definition

Identity Provider (IdP)

Authenticates the user and issues SAML assertions. Examples: Okta Workforce Identity, Azure AD, ADFS.

Service Provider (SP)

Consumes assertions and grants access to protected resources. Examples: Salesforce, Slack, SSOJet-enabled apps.

Assertion

An XML document containing the user’s identity, attributes, and authorization decision. Always signed; may be encrypted.

Attribute

A user property such as email, givenName, role, or group. Passed inside the assertion for fine-grained access control.

NameID

A unique identifier for the subject (user). Can be an email, UUID, opaque alias, or persistent/temporary pseudonym.

Metadata

XML files exchanged by IdP and SP that describe endpoints, certificates, supported bindings, and entity IDs—forming the basis of trust.

Binding

The transport mechanism for SAML messages: HTTP-Redirect, HTTP-POST, HTTP-Artifact, SOAP, PAOS, etc.

Single Logout (SLO)

A protocol extension that terminates the user’s session across all SPs with one action.

Subject

The user (or system) that the assertion is about.

Audience

The intended recipient(s) of the assertion—checked by the SP to prevent token reuse by rogue parties.

How SAML Flows Work

High-Level Steps

  1. Access attempt – User tries to reach a protected SP resource.

  2. Redirection – Depending on the flow, either the SP redirects the browser to the IdP (SP-initiated) or the IdP directly posts the assertion (IdP-initiated).

  3. Authentication – IdP verifies the user (password, MFA, smart card, etc.).

  4. Assertion creation & signing – IdP generates a signed XML assertion with optional encryption.

  5. Assertion delivery – Browser transports the assertion to the SP using HTTP-POST or HTTP-Redirect binding.

  6. Validation – SP validates the signature, confirms audience, checks timestamps, and optionally decrypts.

  7. Attribute consumption – SP reads attributes to build a local user session / map roles.

  8. Session establishment – User gains access; subsequent logins to other SPs skip steps 3-4 (SSO).

Practical Use Cases

1. Workforce SSO (Internal)

Enterprises unify access to email, HR portals, Git repositories, and on-premise apps with one corporate identity store (e.g., Active Directory + ADFS). SAML’s mature spec, SLO support, and attribute mappings make it the default choice for regulated industries.

2. B2B SaaS SSO (Customer-Hosted IdPs)

If your SaaS product targets mid-market or enterprise customers, you must integrate SAML so clients can connect their IdPs (Okta, Ping, Azure AD). SSOJet accelerates this by providing pre-built connectors to 25+ IdPs with minimal code.

3. Government Portals & Higher Education Federations

Initiatives like US FedRAMP, EduGAIN, and InCommon rely on SAML to let citizens or students use a single digital identity across many agencies or universities.

4. Cross-Domain Identity Federation

Large conglomerates or supply-chain partners can establish federations to share apps securely without duplicating user directories.

Sample SAML Response (Truncated)

<samlp:Response

ID="_257f9d9e9fa14962c0803903a6ccad931245264310738"

Version="2.0"

IssueInstant="2009-06-17T18:45:10.738Z">

<saml:Issuer

Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">

https://www.salesforce.com

</saml:Issuer>

<samlp:Status>

<samlp:StatusCode

Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>

</samlp:Status>

<saml:Assertion

ID="_3c39bc0fe7b13769cab2f6f45eba801b1245264310738"

Version="2.0"

IssueInstant="2009-06-17T18:45:10.738Z">

<!-- Signature, Subject, Conditions, AuthnStatement... -->

</saml:Assertion>

</samlp:Response>

Tip for Developers Use an XML Signature validator and the IdP’s x.509 certificate to verify the <ds:Signature> element during troubleshooting.

Security Best Practices

  1. Always validate signatures and certificate chains on every assertion and metadata file.

  2. Enforce short assertion lifetimes (minutes, not hours) and check NotBefore/NotOnOrAfter.

  3. Turn on assertion encryption when sensitive attributes (PII) are present.

  4. Implement Single Logout to prevent orphaned sessions.

  5. Pin metadata endpoints (entity IDs and certificate fingerprints) to detect rogue IdPs or SPs.

  6. Use strong NameID formats (persistent or email) instead of unspecified.

  7. Prefer SHA-256/512 signature algorithms; deprecate RSA-SHA1.

Limitations & Alternatives

Limitation

Modern Alternative

Verbose XML, harder in mobile

OIDC (OAuth 2.0 + JWT) uses compact JSON Web Tokens.

Browser-centric bindings

OAuth Device Flow or PKCE for native apps.

Real-time token revocation is complex

SCIM + OAuth introspection simplify de-provisioning.

Partial support for social logins

OIDC excels at B2C and hybrid identity.

SAML still excels in enterprise SSO, but many organizations run it alongside OAuth 2.0/OIDC for mobile-first or consumer scenarios.

Conclusion

SAML remains a cornerstone of enterprise identity federation, balancing robust security with a unified user experience. Its rich attribute model, mature tooling, and broad vendor support make it the first choice whenever regulated organizations need to share authentication and authorization data across domains. For modern B2C or mobile-centric apps, consider complementing SAML with OIDC—yet for workforce SSO and B2B SaaS integrations, SAML is still king.

Need to add SAML to your SaaS fast? SSOJet provides turnkey, developer-friendly SAML and SCIM connectors so you can become enterprise-ready in minutes.

0
Subscribe to my newsletter

Read articles from Andy Agarwal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Andy Agarwal
Andy Agarwal