Authentication, Identity & AccessSetup guide3 min readUpdated September 2026

Adding SAML SSO to a B2B SaaS App: Design and Steps

Adding SAML SSO to a B2B SaaS app means letting each customer connect their own identity provider so their employees sign in with company credentials. You store a SAML connection per organization, route users by email domain, validate signed assertions, and map the result to a member of that organization.

The protocol is well documented. What trips teams up is the per-customer configuration, testing and the account-linking rules.

Vendors Covered in this Article

Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.

How does the SAML flow work between your app and the customer?

Your app is the service provider (SP) and the customer's system is the identity provider (IdP). In the common SP-initiated flow, a user enters their email, you find the organization's connection, and redirect them to the IdP with an authentication request. The IdP authenticates them and posts a signed assertion back to your assertion consumer service (ACS) URL. You verify the signature, check the audience and timing, and start a session.

Each side needs to share configuration: you give the customer your entity ID and ACS URL, and they give you their sign-in URL, entity ID and signing certificate, usually as a metadata file. Make these easy to copy in a settings page, since customers' IT teams will do this without you on the call.

What should your data model and settings screen include?

Plan for many customers with different setups:

  • An SSO connection record per organization with the IdP's metadata, certificate and status.
  • Verified email domains per organization, proven by a DNS record, so nobody can claim someone else's domain.
  • Attribute mapping for email, first and last name, and optionally groups or roles.
  • A setting to require SSO for the organization, which disables password and social login for its members.
  • A test-connection button and a log of recent SSO attempts with readable errors, which will save many support hours.

Tenant modeling matters here: the organization, not the user, owns the connection.

How to implement it step by step

A sequence that works for most teams:

  1. Add organizations, memberships and verified domains to your data model if they don't exist.
  2. Choose a SAML library or provider rather than writing signature validation yourself.
  3. Build the SP endpoints: metadata, login initiation and ACS.
  4. Validate every assertion: signature, issuer, audience, recipient, expiry and replay protection.
  5. Map attributes to a user and membership, creating them on first login (just-in-time provisioning) if allowed.
  6. Test with a free test identity provider and then with a real customer in a pilot.
  7. Document setup for the most common identity providers your customers use.

Never trust an unsigned or unverified assertion, and reject assertions meant for a different audience. These checks are the security of the whole feature.

What about provisioning, deprovisioning and account linking?

Login is half the job. When an employee leaves the customer, their access should end quickly. Just-in-time creation handles arrivals but not departures; SCIM, a provisioning standard, lets the customer's directory create and disable users in your app automatically. Enterprises often ask for it after SSO, so design for it early even if you ship it later.

Account linking is the classic vulnerability. If someone already has a password account with an email in a verified SSO domain, decide how to merge without letting an attacker take over accounts. Only link when the domain is verified for the organization, and require the organization to own it. Session length and single logout are further customer requests to plan for.

Should you build it or use a provider?

SAML has many edge cases, such as certificate rotation, clock skew, encrypted assertions and identity providers that deviate from the standard. Providers such as Auth0 and Clerk sell B2B connections so you configure per-organization SSO instead of implementing the protocol. Check in a demo how each represents organizations, whether customers can self-serve setup, and what SSO costs per connection, since pricing structures differ.

If SSO is the only enterprise feature you need, building may be reasonable with a good library. If you also need SCIM, audit logs and many customers, buying usually costs less than the maintenance. Side-by-side detail is in Auth0 vs Clerk vs Stytch, Clerk vs Auth0 for B2B SaaS and Auth0 vs Clerk for software publishers.

Executive Capability Standard

What Good Looks Like

Each customer organization can connect its identity provider through a self-service screen, and every assertion is fully validated before a session starts.

Building The Capability (5-Stage Skill Ladder)

1. Learn:Read a SAML flow walkthrough and list which of your customers already ask for SSO.
2. Do Manually:Wire one test connection using a free test identity provider and validate the full login flow end to end.
3. Delegate:Assign an engineer to own SSO support, including a runbook for common customer misconfigurations.
4. Automate:Add domain verification, a self-serve settings page, connection tests and logs of SSO attempts.
5. Buy:Use a B2B identity provider when you need many connections, SCIM and audit logs without maintaining the protocol.

How to Get Started

Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.

Auth0

Fits when customers use many different identity providers and you need broad SAML and federation support.

Visit Auth0→
Clerk

Fits when you want organizations and self-serve SAML connections that match a React or Next.js app.

Visit Clerk→

Frequently Asked Questions

What is the difference between SP-initiated and IdP-initiated SAML?

SP-initiated starts at your app, which redirects to the identity provider. IdP-initiated starts from the customer's portal and posts an assertion to you unsolicited. SP-initiated is safer, so support IdP-initiated only if customers ask.

How do I know which identity provider a user belongs to?

Route by verified email domain. Each organization proves ownership of its domains through DNS, and you look up the connection for the domain the user types on the login page.

What is SCIM and do I need it?

SCIM is a standard for automatically creating and disabling users from a customer's directory. It's not required for SAML login, but enterprise customers often ask for it so departures remove access promptly.

Should I build SAML myself?

Only if you need a narrow feature and have a strong library and security review. Most B2B teams use a provider or a maintained library, since signature validation and certificate handling are easy to get wrong.

About the numbers

This guide doesn't quote a sourced benchmark. Figures in it are estimates or general guidance, so check them against your own numbers.

Related Guides