DEV Community

WizCodes
WizCodes

Posted on Originally published at wizcodes.site

How to Add SSO to a Web App (Without Breaking Deals)

Single Sign-On is how your app lets enterprise customers log in through their own company directory instead of creating yet another username and password. Most B2B software teams add SSO because a sales deal requires it, then discover the integration they built only works for half their enterprise pipeline. The problem is deciding which identity providers to support and in what order, because that choice determines whether your next three contracts can actually go live.

What SSO actually means for B2B software

SSO is a login shortcut. It helps enterprise customers onboard their teams faster. When a company runs on Google Workspace or Microsoft 365, their employees expect to click one button and land inside your product already logged in.

Without SSO, each person creates a password, verifies their email, and manages another credential. IT teams hate this. You lose deals because procurement wants everything tied to their existing identity provider - the system that already controls access to email, Slack, and internal tools.

SSO solves both problems. A user clicks "Sign in with Google" or "Sign in with Microsoft," your app confirms their identity with the provider, and you create their account automatically. Their company controls access from one dashboard instead of chasing offboarding requests across dozens of tools.

SSO does not replace user permissions inside your app. It authenticates the person, but your system still decides what they can do once they are in.

The mechanism is straightforward. The real decision is whether your customer segment expects it now or whether email and password gets you to revenue faster.

How SSO works, step by step

SSO sits between your user, their company's identity system, and your application. Someone tries to log in. Your app redirects them to their company's identity provider. That provider checks who they are, confirms they are allowed in, and sends a signed token back to your app. Your app reads the token, creates a session, and lets them through.

The protocol layer does the heavy lifting. SAML and OIDC define how the identity provider and your app exchange information without either one trusting the other directly. The provider signs the token with a certificate. Your app checks the signature, extracts the user's email and role, and either finds their existing account or creates one on the fly. Most integration bugs surface at that provisioning step - mismatched email formats, missing role mappings, or accounts that get duplicated instead of matched.

Routing happens first, before any authentication. Your app needs to know which identity provider to send each user to. Once the redirect completes and the token arrives, the protocol layer validates it and your app builds the session. We handle this end-to-end when building full-stack web apps, including the edge cases around role sync and account linking that break SSO in production.

What it looks like in a real build

We built SSO into a custom CRM for a client who sold into enterprises. Their buyers expected Okta and Azure AD login. No exceptions.

User clicks login. We redirect to their identity provider. They authenticate there. The provider returns an assertion. We validate it and create a session. Failure points cluster at validation and session creation.

Claim mapping is where most teams get stuck. The IdP sends email, name, and group memberships. Your app needs to decide which group maps to which role, and whether missing claims block login or default to viewer. That decision belongs in the validation step, not the session layer.

Another common trap is treating SSO as the only auth method. Enterprise customers want SSO. Individual users still need email login. We route by domain - corporate emails trigger SSO, everything else hits the standard flow. That routing decision happens before the redirect, and it determines which custom fields you need to store per account.

Where teams get the routing decision wrong

Most teams ask "which SSO protocol should we use" before they know who will actually sign in. Protocol follows provider. You need to know what identity system your customer's IT team already runs to manage their employees.

Picking SAML because it sounds enterprise-grade, then discovering your target customers all use Okta with OIDC endpoints - that is the mistake. Or choosing OIDC for its clean token flow, then losing a deal because the customer's on-premise Active Directory only speaks SAML.

Ask your first three enterprise prospects what identity provider their IT team uses. That tells you the protocol. If they are split between modern cloud providers and legacy systems, you need both - but build the one your paying customers need first, not the one that looks cleaner in the architecture diagram.

The routing layer sits behind your login screen. When a user from acmecorp.com hits sign-in, your backend looks up their tenant record, sees they are configured for OIDC with Azure AD, and redirects them there. A user from oldschool-inc.com gets routed to their SAML endpoint instead. One login screen, two authentication paths. Start a project if you need that logic built and tested before your first enterprise customer signs the contract.

How to tell whether you need it now

You need SSO when a customer asks for it by name or blocks a contract on it. That is the trigger. Before that moment, username and password work fine.

The question is whether the customer who is writing you a check requires it to sign. If three enterprise prospects ask for SAML in the same quarter, SSO moves to the build list. If no one has mentioned it recently, it stays off.

Start with a short list of target customers and their identity providers. If four of your top five prospects use Okta with SAML, build SAML support. If they use Google Workspace, an OAuth flow covers them. The protocol decision comes from the customer list, not from what sounds more robust.

Do not build SSO to look enterprise-ready. Build it when losing a real contract hurts more than the integration work.

Top comments (0)