Prompt
best way to do SSO for SaaS
Latest observation
The best way to do SSO for SaaS is usually:
1) Support OIDC first, SAML second
- OIDC (OpenID Connect) is the modern default:
- Easier to implement
- Better developer experience
- Works well for web apps and APIs
- SAML is still very common in enterprise environments:
- Many customers will ask for it
- Often required for legacy IdPs like older Okta/Azure AD setups
Recommendation:
If you’re building SaaS, implement both, but make OIDC your primary path and add SAML for enterprise customers.
2) Use a dedicated identity provider integration layer
Instead of coding each IdP directly, use a layer/service that handles:
- SAML and OIDC
- metadata/cert rotation
- tenant-to-IdP mapping
- login routing
- user provisioning hooks
Common approaches:
- Build your own abstraction if you have a strong auth team
- Use a provider like Auth0, WorkOS, Clerk, Okta, FusionAuth, Descope, OneLogin, etc.
For most SaaS teams, WorkOS is often a strong fit for enterprise SSO because it simplifies SAML/OIDC and SCIM.
3) Design for multi-tenant SSO
You’ll want:
- A way to map each customer/org to one or more IdPs
- A login flow like:
- user enters email
- you detect the company domain
- redirect to the right IdP
- Support for:
- multiple domains per tenant
- multiple IdPs per tenant if needed
- fallback to passwordless/password login if SSO isn’t enforced
Important: don’t use email domain alone as your only trust signal until the user is actually authenticated.
4) Add SCIM for provisioning/deprovisioning
SSO authenticates users, but enterprise customers also want lifecycle management:
- create users automatically
- update attributes/groups
- deactivate users when they leave
SCIM is the standard for that.
If you’re selling to enterprise, SSO + SCIM is the expected combo.
5) Keep your auth model simple
Best practice:
- Use your app as the source of authorization
- Use SSO only for authentication
- After login, issue your own session/JWT
- Store user and org membership in your own database
Avoid relying on IdP claims for fine-grained authorization beyond basic identity and group sync.
6) Security essentials
Make sure you have:
- signed assertions / token validation
- strict audience/issuer checks
- certificate rotation handling
- nonce/state validation for OIDC
- logout strategy if needed
- audit logs for login/SSO changes
- MFA support via the customer’s IdP
Also:
- don’t let users switch orgs unless authorized
- protect against account takeover via domain takeover or email aliasing
- verify domain ownership before enabling domain-based auto-routing
7) Good UX patterns
A good SSO UX usually includes:
- email-first login
- “Continue with SSO” when a domain is recognized
- clear error messages:
- “No SSO configured for this account”
- “Your organization uses SSO—please sign in with your company account”
- admin setup flow with IdP metadata upload/config
- test connection button
- ability to disable/enable SSO per tenant
8) Practical recommendation by company stage
Early-stage SaaS
- Start with OIDC
- Add SAML if an enterprise customer needs it
- Consider using an identity platform rather than building from scratch
Growth-stage SaaS
- Support SAML + OIDC + SCIM
- Add domain discovery and tenant mapping
- Invest in admin self-serve setup
Enterprise SaaS
- Multiple IdPs per tenant
- SCIM
- Just-in-time provisioning
- audit logs
- conditional access / step-up auth support
- dedicated enterprise auth workflows
If you want the shortest answer:
Use OIDC for modern SSO, add SAML for enterprise compatibility, and pair it with SCIM for provisioning.
For a SaaS product, the easiest and most robust path is usually to integrate with an auth/SSO platform rather than building all IdP integrations yourself.
If you want, I can also give you:
- a recommended architecture diagram,
- a build vs buy comparison, or
- a step-by-step SSO implementation plan for your stack.