Updated November 30, 2026. Published by Frontegg, which sells customer identity, so we have a stake in "buy". This guide ties what you'd build to published security standards, shows every cost input, and says when building or self-hosting is the right call.
Short answer: build your own authentication only if identity is part of your product, or you must run without any external identity service. If you need to keep data in your own infrastructure, self-hosting an open-source server such as Keycloak is usually faster than building. Most B2B SaaS teams buy, because enterprise customers soon ask for SAML SSO and SCIM provisioning. Vendor estimates put those two features at roughly 900 to 1,000 engineering hours to build, before maintenance.
Your five options, not two
"Build or buy" hides five different choices. They differ in what you write, what you run, and who patches it.
| Option | You build | You run | Typical fit |
|---|---|---|---|
| Build from scratch | Everything: login, sessions, MFA, SSO, SCIM, tenants, admin UI | Everything | Identity is your product, or no external service is allowed |
| Libraries (e.g. Passport.js, Auth.js, framework auth) | Tenants, SSO, SCIM, admin UI, security operations | Everything | Early products with simple login and no enterprise customers yet |
| Self-hosted open source (Keycloak, Ory, Zitadel) | Customization and a customer-facing admin UI | Servers, patching, scaling, backups | Data must stay in your infrastructure, and you have ops capacity |
| Enterprise SSO and SCIM APIs beside your own login (e.g. WorkOS, which also sells full login) | Login, sessions, tenants, roles | Your login stack | You already have login and need enterprise features fast |
| Managed customer identity (e.g. Auth0, Clerk, Descope, Stytch, Frontegg) | Integration and branding | Your app only | You want engineering time on your product |
What authentication means once you sell to businesses
A B2B login has to meet the standards enterprise security reviews check against. OWASP's Application Security Verification Standard (ASVS 5.0, May 2025) has 139 requirements across authentication, sessions, authorization, tokens, OAuth/OIDC and logging (our count of its chapters). NIST SP 800-63B-4 (final, July 2025) sets the bar for passwords, MFA and recovery. The split below into "before" and "after" the first enterprise deal is our judgment from typical procurement questionnaires, not a standard.
Before your first enterprise deal
- Password storage with a salted, slow hash, and a 15-character minimum when a password is the only factor (NIST SP 800-63B-4; OWASP Password Storage Cheat Sheet).
- Rate limiting of failed sign-ins: NIST allows no more than 100 consecutive failed attempts on one account. Add protection against credential stuffing.
- MFA, including a phishing-resistant option such as passkeys, which NIST requires verifiers to offer at assurance level 2.
- Session management: expiry, revocation, sign-out everywhere.
- Account recovery that follows NIST's recovery rules, so it can't become a takeover path.
- Per-customer SAML and OIDC single sign-on. Each enterprise customer brings its own identity provider, such as Okta, Microsoft Entra ID, Google Workspace or Ping. You need per-tenant configuration, certificate rotation and safe XML signature validation (OWASP SAML Security Cheat Sheet).
- Tenant isolation. ASVS 5.0 requirement 8.4.1 (Level 2) requires controls that stop one customer's users from reaching another customer's data.
Usually asked for within the first few enterprise deals
- SCIM 2.0 provisioning, so customers' IT teams add and remove users from their directory (RFC 7643, RFC 7644).
- Roles and permissions per customer account.
- Audit logs customers can see or export.
- A self-service admin area where customers' admins manage users, roles and SSO. No standard requires it; enterprise buyers expect it, and it saves support tickets.
Ongoing
- Library patches (see below), certificate expiries, identity provider changes, new standards such as passkeys and OAuth 2.1, and a security review in every enterprise procurement.
Where homegrown authentication breaks
The serious bugs sit in parsing and token handling, not in the login form.
- SAML signature wrapping: 11 of 14 SAML frameworks tested let attackers sign in as other users (On Breaking SAML, USENIX Security 2012).
- SAML comment parsing: one bug affected python-saml, ruby-saml, saml2-js and OpenSAML at once (CERT VU#475445, 2018).
- ruby-saml authentication bypass: CVE-2024-45409, CVSS 10.0, and CVE-2025-25291 and CVE-2025-25292, a parser difference exploitable in GitLab.
- JWT "alg: none" and key confusion: libraries accepted unsigned tokens or mixed up public and secret keys (CVE-2015-9235, CVE-2015-2951).
- The OWASP Top 10:2025 ranks Broken Access Control first and Authentication Failures seventh.
Buying doesn't remove these risks; it moves patching to a team that does it full-time. If you build, someone must watch these advisories and ship fixes fast.
What building costs: a model you can fill in
No independent study measures how long authentication, SSO or SCIM takes to build. The published estimates come from vendors who sell the alternative, so read them as ranges.
| Source (vendor) | Estimate |
|---|---|
| WorkOS (2024) | SSO: 400 hours + 40 per identity provider; about 3 months with 3 engineers. SCIM: 600 hours + 80 per identity provider; just under 4 months |
| SSOJet (2026) | Enterprise SSO, SCIM and audit logs: 113 engineer-days to build, 80 a year to maintain |
| Supabase (2025) | SAML SSO: 8 weeks or more |
Formula: (build hours + yearly maintenance hours × years) × your hourly cost.
Hourly cost: US median pay for software developers is $135,980 a year (BLS, May 2025), about $65 an hour. Wages are about 70% of what employers spend per employee (BLS employer costs, June 2026), so a loaded median cost is about $93 an hour. Use your own rate.
Worked example at $93 an hour:
- WorkOS's base estimate for SSO plus SCIM (1,000 hours): about $93,000 to build, before per-provider work.
- SSOJet's estimate (113 days to build, 80 a year to maintain, on 220 working days a year): about $100,000 to build and $71,000 a year to keep running. That is about $312,000 over three years.
What buying costs over the same three years (list prices, 7,500 monthly users, from our cost comparison):
| Scenario | Monthly, Auth0 / Clerk / Frontegg / WorkOS | Three years |
|---|---|---|
| 5 enterprise customers on SSO | $0 to $1,800 | $0 to $64,800 |
| 10 customers on SSO and SCIM | $1,475 to $2,500 | $53,100 to $90,000 |
Buying has its own costs: integration work, prices that grow with users and connections, dependence on the vendor's uptime, and one more subprocessor in your customers' security reviews.
When building or self-hosting is the right call
Build when identity is the product; self-host when the data can't leave your servers.
- Build: identity is your product or a core differentiator, or you need flows no provider supports through hooks or APIs.
- Self-host open source: on-premises or air-gapped deployments, or strict data control. OpenTalk chose Keycloak for on-premises data control instead of building its own (CNCF case study). BRZ moved an Austrian business portal with more than 2 million users to Keycloak (CNCF case study). Budget for servers, upgrades and an admin UI for your customers.
- Either way: you need at least one engineer with identity and security experience for years, not one sprint.
Questions to answer before you decide
- How many enterprise customers will ask for SSO in the next 12 months, and which identity providers do they use?
- Will those deals need SCIM, customer-visible audit logs or a customer admin area?
- Where must user data live, and can it leave your infrastructure?
- Who maintains authentication in two years, and what would that person build instead?
- If you buy, how would you leave? Check that you can export users, password hashes and organization data.
Related guides
Put this into practice with Frontegg
Frontegg is customer identity and access management (CIAM) for B2B SaaS. It's free up to 7,500 monthly active users, including 5 SSO/SCIM connections.
Start for free