Passwords & identity

What Is SAML? How SAML SSO Works, Assertions and Security

SAML lets your staff sign in once and reach dozens of apps without another password. Here is how the protocol works, where it fits, and the mistakes that break it.

Cysoro Security TeamPublished · 10 min read
IdPIdentity providerSigns you in once SPService providerTrusts the assertion <Assertion> signed XMLIdentity, attributes, time window PASSWORDS & IDENTITY What isSAML? One login. Every app.
Quick answer

SAML (Security Assertion Markup Language) is an XML-based open standard that lets an identity provider prove a user's identity to a separate application, so the user signs in once and gains access to many apps. The identity provider sends a digitally signed XML document called an assertion to the application, which checks the signature and starts a session without ever seeing the user's password.

Key takeaways

  • SAML is a protocol for single sign-on: one login at an identity provider unlocks many applications.
  • A signed XML assertion carries the user's identity and attributes from the identity provider to the application.
  • SAML suits enterprise and government SSO; modern consumer and mobile apps usually prefer OpenID Connect.

If you work at a company with more than a handful of apps, you have probably used SAML without knowing it. You sign in once in the morning, then open your email, your project tracker and your HR system without typing another password. SAML is the protocol that makes that possible.

What is SAML?

SAML, or Security Assertion Markup Language, is an XML-based open standard for exchanging authentication and authorization data between two parties. It lets an identity provider vouch for a user to an application, so the application trusts that proof instead of asking for a password itself.

SAML 2.0 was ratified as an OASIS open standard in 2005. Two decades later it remains widely used for enterprise and government identity federation, even as OpenID Connect has become more common for modern applications.

The key idea is federation: separate security domains trust each other. Your company identity provider holds the accounts and checks passwords and MFA. Each application trusts the identity provider, so it does not need its own copy of your password.

SAML is not a product and not a login page. It is a set of rules for messages, formats and trust relationships. Identity providers such as Microsoft Entra ID, Okta and Google Workspace implement it, and thousands of business applications accept it.

How does SAML work?

SAML works through three actors: the user, the identity provider (IdP) and the service provider (SP). The IdP authenticates the user, then sends a signed XML assertion to the SP, which checks the signature and starts a session for that user.

How a SAML login flows1User opensthe app(service provider)2App redirectsto the identityprovider3User signs inpassword plusMFA if set4IdP creates asigned SAMLassertion5Browser sendsassertion backto the app6App checks itand grantsaccessThe application never sees the password. It trusts the signed assertion instead.Everything travels through the browser, so no direct network path is needed.
The six steps of a SAML login. Illustration by Cysoro.

Here is the usual SP-initiated flow, step by step:

  1. You open an application, the service provider.
  2. The application sees you are not signed in and redirects your browser to the identity provider with a SAML authentication request.
  3. You sign in at the identity provider, which may ask for MFA.
  4. The identity provider creates a SAML response containing a signed assertion.
  5. Your browser carries that response back to the application, usually by HTTP-POST.
  6. The application validates the signature, checks the audience and time window, and creates a session for you.

There is also an IdP-initiated flow. You start at your company portal, click an app tile, and the identity provider sends an unsolicited assertion to that app. It is convenient, but it needs extra care around replay protection because there is no original request to match against.

What are the parts of SAML?

SAML has three core components: the identity provider, the service provider and the assertion. Trust between the first two is set up in advance through exchanged metadata, including endpoints, entity IDs and signing certificates.

The identity provider (IdP) holds the accounts and authenticates users. Examples include Microsoft Entra ID, Okta, Google Workspace and Keycloak. The IdP is the only party that sees the password.

The service provider (SP) is the application you want to use, such as a CRM, a helpdesk or a code repository. It relies on the IdP for authentication and grants access based on the assertion.

The SAML assertion is the signed XML document that carries the proof. It includes the issuer (which IdP created it), the subject (who the user is), conditions (a validity time window and the intended audience), a signature, and statements about the user.

Metadata exchange is what makes the trust real. The IdP publishes its SSO endpoint and signing certificate, and the SP publishes its assertion consumer service URL. Each side imports the other's metadata, and the SP uses the certificate to verify signatures.

What is inside a SAML assertion?

A SAML assertion contains three kinds of statements. Authentication statements confirm the user signed in and when. Attribute statements carry user data such as email, name, groups and roles. Authorization decision statements exist in the specification but are rarely used in practice.

Attribute statements do most of the practical work. They let the application know who you are and what you may do, without a separate lookup. A common pattern is to pass group membership, so the application can map groups to roles and permissions.

Assertions also carry conditions the application must check: the NotBefore and NotOnOrAfter time window, the intended audience, and the recipient URL. An assertion presented to the wrong application, or outside its time window, must be rejected.

The assertion may be encrypted, usually the assertion element itself rather than the whole response. Encryption protects sensitive attributes, but the application must be able to decrypt them, so test this before going live.

SAML vs OAuth vs OpenID Connect: what is the difference?

SAML, OAuth 2.0 and OpenID Connect solve different problems, and confusing them is the most common mistake in identity projects. SAML handles enterprise authentication and SSO. OAuth 2.0 handles delegated authorization. OpenID Connect adds authentication on top of OAuth 2.0 for modern apps.

SAML 2.0OAuth 2.0OpenID Connect
Main jobEnterprise SSO and authenticationDelegated authorization (API access)Modern authentication
FormatXML assertionsTokens, often JWTsJSON, JWT ID tokens
Best forWorkforce apps, government, B2B SaaSThird-party API accessConsumer apps, mobile, modern web
Mobile supportPoor, often needs a browser or broker appExcellentExcellent
Typical useEmployee signs in once, opens many appsApp reads your calendar on your behalfSign in with Google on a website

OAuth 2.0 alone is not an authentication protocol. It answers "what can this app do on my behalf?", not "who is this user?" OpenID Connect fills that gap with a standard ID token. SAML, by contrast, was designed for authentication from the start and can carry authorization attributes such as roles.

The protocols are not mutually exclusive. Many identity platforms support all three, so you can offer SAML to enterprise customers and OpenID Connect to everyone else. If you are building a consumer app or a mobile app, start with OpenID Connect. If enterprise customers demand SSO, you will almost certainly need SAML too.

What are the benefits of SAML SSO?

The biggest benefit is fewer passwords. Users sign in once and reach many applications, which cuts password fatigue and the helpdesk tickets that come with forgotten passwords. It also means fewer passwords stored in fewer places.

Central control is the second benefit. When someone leaves, disabling one identity provider account cuts their access to every connected app. You can also enforce MFA once, at the IdP, instead of configuring it in every application.

SAML also improves auditing. The IdP logs every sign-in, so your security team has one place to review who accessed what and when. That single view is hard to get when each app runs its own login.

For software vendors, SAML support is often a sales requirement. Large customers will not buy a business application that cannot connect to their identity provider, so SAML is a standard checkbox in enterprise procurement.

Is SAML secure? What can go wrong?

SAML is secure when implemented correctly, but its security rests entirely on signature validation. A single mistake there can let an attacker forge a login and walk into an application as any user.

The best-known weakness is XML signature wrapping. An attacker takes a valid signed assertion, moves the signature to a different part of the document, and inserts a forged assertion that the application then trusts. Applications must verify that the signed element is the same element they process, and reject weak algorithms such as SHA-1.

Replay attacks are another risk. The SAML specification does not mandate one-time use of assertions, so the application must store assertion IDs and reject any it has already seen. It must also check the time window, audience, issuer, recipient and, for SP-initiated flows, the request ID.

Clock skew causes its own failures. If the IdP and SP clocks disagree by more than a few minutes, valid assertions get rejected. Allow a small tolerance of two to five minutes and keep servers on reliable time synchronization.

Finally, SAML does not protect you if the IdP account itself is compromised. That is why phishing-resistant MFA matters. US agencies recommend phishing-resistant MFA in their joint phishing guidance, and it applies at the IdP first, because that one login unlocks everything else.

Never skip signature validationEven in development, always validate the SAML signature, certificate chain and assertion conditions. An application that accepts unsigned or unchecked assertions is effectively open to anyone who can craft XML.

How do you set up SAML SSO?

Setting up SAML is mostly configuration, not code, when you use a mature identity provider and a tested library. The steps below work for most integrations.

  1. Choose the IdP and SP roles. Decide which system authenticates users and which application will trust it.
  2. Exchange metadata. Import the IdP metadata into the SP and the SP metadata into the IdP, including entity IDs, endpoints and certificates.
  3. Map attributes. Agree which attributes the IdP sends, such as email and groups, and map them to the application's user fields. Attribute names differ between IdPs, so do not hard-code them.
  4. Enforce MFA at the IdP. Require MFA before the IdP issues an assertion, ideally with passkeys or a security key.
  5. Test with several IdPs. Each IdP implements SAML slightly differently. Test clock skew, certificate rotation, expired assertions, invalid signatures and replayed assertions.
  6. Plan certificate rotation. When the IdP rotates its signing certificate, update the SP configuration before the old one expires, or logins will break.

Do not build a SAML implementation from scratch unless you are building an identity provider. Use a tested library for your stack, such as passport-saml or samlify for Node.js, python3-saml for Python, or Spring Security SAML for Java. Even mature libraries do not handle everything automatically, so you still need to implement replay protection and decryption yourself where required.

Single logout is worth planning but is often fragile. SAML supports single logout, letting a user sign out of all connected apps at once, but implementations vary between providers. Test it with each IdP you support and do not assume it works everywhere.

When should you choose SAML over OpenID Connect?

Choose SAML when your customers are enterprises with existing SAML infrastructure, when you are building B2B software that needs enterprise SSO, when you integrate with government systems, or when a tender requires SAML support. In those cases SAML is not optional.

Choose OpenID Connect when you are building consumer applications, mobile apps, or API authorization, or when you want a simpler JSON-based protocol and are starting fresh without legacy requirements.

Most real systems end up supporting both. Your identity provider can offer SAML to enterprise customers and OpenID Connect to everyone else, and some platforms translate between the two. That flexibility is usually the right answer for a growing product.

SAML or OpenID Connect? Decide by audienceChoose SAML whenEnterprise or government customersB2B SaaS needing enterprise SSOExisting SAML infrastructureA tender or RFP requires itXML assertions, browser-basedChoose OpenID Connect whenConsumer or mobile applicationsAPI authorization is neededSimpler JSON protocol preferredStarting fresh, no legacy SSOJSON tokens, built on OAuth 2.0Many platforms support both — offer SAML to enterprises and OIDC to everyone else.
Choosing between SAML and OpenID Connect. Illustration by Cysoro.

Weak passwords still undermine SSO, because one stolen IdP password can unlock every connected app. Check that your own passwords are not already exposed with our pwned password checker.

For any account that still needs its own password, use a password generator to create one that is long and unique.

Common SAML mistakes to avoid

Most SAML failures are configuration errors, not protocol flaws. The common ones are easy to prevent once you know them.

  • Skipping signature validation. The most dangerous mistake. Every assertion must be validated, every time.
  • Ignoring the audience and time window. An assertion for another app, or one that has expired, must be rejected.
  • Hard-coding attribute names. Different IdPs send different attribute names. Make mapping configurable.
  • Forgetting certificate rotation. Expired IdP certificates break every login at once. Track expiry dates and test rotation.
  • Treating IdP-initiated SSO as equally safe. It has no request to match, so replay protection and timestamp checks matter even more.
  • Using HTTP for the assertion consumer service. Assertions must travel over HTTPS only, or they can be intercepted.

When logins fail, check the basics first: clock skew, certificate expiry, audience mismatch and attribute mapping. Log validation failures separately so you can tell a configuration error from an attack.

The bottom line

SAML is the quiet workhorse of enterprise login. One sign-in at your identity provider, a signed XML assertion, and your staff can open every work app without another password. It is old, XML-based and sometimes clumsy, but it remains the standard large customers expect.

Use it where it fits, secure it properly, and pair it with phishing-resistant MFA at the identity provider. If you are choosing tools for a wider identity project, our guide to the best compliance automation tools for startups shows how SSO and MFA checks fit into audit-ready programs.

Frequently asked questions

What does SAML stand for?

SAML stands for Security Assertion Markup Language. It is an XML-based open standard for exchanging authentication and authorization data between an identity provider and an application.

What is SAML used for?

SAML is mainly used for single sign-on in enterprises and government. An employee signs in once at the company identity provider and then opens many work applications without entering a password again.

Is SAML the same as SSO?

No. SSO, or single sign-on, is the experience of signing in once to reach many apps. SAML is one protocol that makes SSO possible. Other protocols, such as OpenID Connect, can also deliver SSO.

What is a SAML assertion?

A SAML assertion is a digitally signed XML document sent by the identity provider to the application. It states who the user is, when they signed in, and which attributes apply to them, such as their email address, name, groups or roles.

What is the difference between SAML and OAuth?

SAML is mainly for authentication and enterprise SSO, using XML assertions. OAuth 2.0 is for delegated authorization, letting an app access resources on your behalf, and it is not an authentication protocol on its own.

Is SAML secure?

SAML is secure when implemented correctly: assertions must be signed and validated, sent over HTTPS, checked for audience and time window, and protected against replay. Skipping signature validation or using weak algorithms can let an attacker forge a login.

What is the difference between SAML and OpenID Connect?

SAML uses XML and is common in enterprise and government SSO. OpenID Connect uses JSON, builds on OAuth 2.0, and is simpler for modern web, mobile and consumer apps. Many identity platforms support both.

Do I need SAML for a small business?

Probably not at first. Small teams usually get SSO through their identity provider, such as Microsoft Entra ID or Google Workspace, which supports SAML behind the scenes. You need to understand SAML when you connect enterprise apps or sell software to large customers who require it.

Sources

  1. Auth0 — What is SAML 2.0?
  2. Kestra — SAML SSO Integration: Architecture and Protocol Guide
  3. Casdoor — What Is SAML? Assertions, Bindings and Metadata
  4. CISA — Phishing Guidance: Stopping the Attack Cycle at Phase One
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the OASIS SAML 2.0 standard via Auth0's SAML guide, with CISA phishing guidance on MFA.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free