By NHI Mgmt Group Editorial TeamBased on Descope: “Adding SSO to Homegrown Authentication With Descope” (September 3, 2025)

TL;DR: Homegrown authentication systems often struggle once enterprise customers demand SSO, because SAML, OIDC, tenant discovery, metadata handling, and IdP-specific routing introduce complexity and security risk, according to Descope. The core issue is that custom auth stacks assume a simple login flow, while enterprise identity requires lifecycle-managed federation and policy control.


At a glance

What this is: This is a Descope walkthrough of why adding enterprise SSO to homegrown authentication creates a control gap around federation, tenant routing, and policy handling.

Why it matters: It matters because IAM teams extending custom login systems must govern identity routing and session control as part of the authentication plane, not bolt SSO on as a thin protocol layer.


Context

Homegrown authentication often starts as a simple email-and-password flow, but enterprise SSO adds routing, federation, metadata exchange, and customer-specific access policy. Once those requirements appear, the problem is no longer just user sign-in. It becomes a governance question about who selects the identity provider, how tenants are identified, and where control over authentication really lives.

In enterprise environments, SSO is tied to lifecycle-managed identity decisions, not only to protocol support. That means custom auth stacks have to handle SAML or OIDC flows, tenant discovery, logout paths, attribute mapping, and per-customer configuration drift without weakening access controls. The article frames this as an enterprise control gap because the original architecture was never built for that operational load.


Key questions

Q: How should teams handle tenant discovery in enterprise SSO integrations?

A: Keep tenant discovery and IdP selection on the server side, where the application can enforce domain-to-tenant rules before redirecting the user. Client-side routing is too easy to influence and turns identity selection into a user-controlled path rather than a governed control point. The right test is whether the backend can make the routing decision without trusting the browser.

Q: When does homegrown authentication become too risky to extend with SSO?

A: It becomes risky when the team can no longer manage tenant-specific routing, metadata, certificates, and callback handling as governed lifecycle assets. At that point, every new enterprise customer adds configuration drift and operational exposure. The warning sign is that authentication changes are consuming more engineering time than core product work.

Q: What breaks when a SAML integration assumes metadata and certificate settings stay static?

A: When metadata or certificates are treated as static, logins eventually fail as identity providers rotate keys, change endpoints, or update bindings. The result is opaque authentication outages that are hard to diagnose and often surface during business hours. Teams also inherit repeated support work because users, admins, and enterprise IT partners all encounter the same fragile configuration.

Q: What is the difference between local sessions and federated authentication?

A: Federated authentication proves identity with an external IdP, while the local session is the application’s own record of that authenticated state. The federation step should be validated before any local token is issued, because the application still controls route access, session scope, and how long that trust lasts. Mixing the two creates confused trust boundaries.


Technical breakdown

Why tenant discovery becomes an identity control point

Tenant discovery is the step that maps a user’s email domain to the correct tenant and identity provider before authentication continues. In a homegrown stack, that logic can sit in the backend, the client, or a mix of both, but only backend-controlled selection prevents users from choosing an IdP they should not control. Once multiple tenants share one app, the routing decision becomes part of the trust boundary, not just a convenience feature.

Practical implication: keep IdP selection server-side and treat tenant discovery as an access control decision, not a UI shortcut.

Why SAML metadata and certificates create lifecycle risk

Enterprise SSO depends on exchanging SAML metadata, certificates, entity IDs, and ACS URLs across tenants. Those values change, expire, and drift over time, which means integration work does not end when the first login succeeds. If a team hand-builds these flows, every customer onboarding can add bespoke configuration, and every IdP update can create breakage or inconsistent trust state across tenants.

Practical implication: inventory SAML configuration as governed lifecycle state and monitor certificate rotation, metadata changes, and tenant-specific drift.

How session issuance changes after federation

Once SSO completes, the backend receives an assertion or code, validates it, and then typically issues its own session or JWT for application use. That means the application still owns session duration, route protection, and downstream authorization even though authentication happened upstream. The security boundary shifts from password verification to token handling, callback validation, and correct binding between the federated identity and the local session.

Practical implication: validate the federation response before minting any local session and bind the resulting token to the tenant and identity that authenticated upstream.


NHI Mgmt Group analysis

SSO integration is an identity governance problem, not a front-end feature. The article shows that enterprise federation changes the trust model around login, tenant selection, and access policy. Once a custom auth stack has to decide which IdP is authoritative, the authentication layer becomes part of IAM governance, not just product plumbing. The practitioner conclusion is that SSO design belongs in the identity architecture, not as an afterthought in application code.

Tenant routing is the control plane in homegrown SSO. Email-domain discovery, IdP selection, and redirect generation determine where trust is placed before the user ever reaches the enterprise IdP. If those decisions are not controlled server-side, the application risks letting the client influence identity routing. The implication is that homegrown authentication must treat routing logic as a privileged control surface.

SSO exposes configuration drift as an authentication risk. SAML metadata, certificates, endpoints, and attribute mappings all change across enterprise customers, which means each new integration can increase operational fragility. This is a lifecycle issue as much as a protocol issue because trust material must be maintained, not merely installed. The practitioner conclusion is to govern federation inputs with the same discipline used for other identity artifacts.

Homegrown auth often underestimates the full SSO lifecycle. The enterprise requirement is not just “support SAML” or “support OIDC.” It is tenant discovery, IdP-specific routing, logout handling, user attributes, and long-term maintenance as providers evolve. That bundle creates an enterprise control gap because simple login assumptions do not scale to federated identity operations. The practitioner conclusion is to redesign authentication around lifecycle-managed federation, not one-off integrations.

From our research library:

  • Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap, according to the State of Secrets in AppSec.
  • AI-related credential leaks surged 81.5% year-over-year in 2025, with the surrounding AI infrastructure leaking 5x faster than core LLM providers, according to the State of Secrets Sprawl 2026.
  • Read next: AI Agent Authorisation Guide

What this signals

Tenant discovery is the control point that many custom auth stacks do not explicitly govern. Once the application decides which IdP should authenticate a user, routing logic becomes part of the trust boundary. Teams should review whether that decision is enforced server-side, logged, and owned as privileged identity code rather than scattered through client flows or one-off integrations.

SAML metadata handling is really lifecycle management for trust material. Certificates, entity IDs, ACS URLs, and attribute mappings all change over time, so the operational question is not whether SSO works once, but whether the programme can survive customer onboarding, IdP updates, and configuration drift without breaking identity assurance.

Enterprise SSO exposes a broader governance gap: authentication and authorization are no longer separable in practice. When a federated identity becomes the basis for local session issuance, teams need clear rules for how upstream trust is translated into downstream access, especially in multi-tenant applications where one login system serves many organisations.


For practitioners

  • Map the tenant-routing trust boundary Document where tenant discovery happens, who can influence it, and how the backend prevents client-driven IdP selection. Treat domain-to-tenant mapping as privileged logic.
  • Govern SAML metadata as lifecycle data Track certificates, entity IDs, ACS URLs, and attribute mappings per tenant, and define ownership for renewals and drift correction before customer onboarding scales.
  • Separate federation from local session logic Validate the upstream SSO response first, then mint application sessions only after the tenant and identity are bound to the authenticated result.

Key takeaways

  • Homegrown authentication systems often fail at the point where enterprise SSO introduces tenant routing, metadata exchange, and policy-managed federation.
  • The operational burden is not just protocol support. It is the lifecycle maintenance of certificates, endpoints, attribute mappings, and tenant-specific trust state.
  • Security teams should treat federated login as an identity architecture decision, with server-side routing and validated session issuance at the centre.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-9 — Identification and Authentication (Non-Organizational Users)Federated enterprise users authenticate through external IdPs in this SSO flow.
IA-5 — Authenticator ManagementCertificates and SAML metadata require lifecycle control across tenants.
Recommendation — Apply IA-9 to validate federated identities before issuing local application sessions. Manage SAML certificates and related authenticators under IA-5 lifecycle controls.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe article centers on who can be routed, authenticated, and granted access.
Recommendation — Enforce PR.AA-05 so identity routing and access decisions stay governed across tenants.
OWASP API Security Top 10API2 — Broken AuthenticationCustom login and callback flows can fail if authentication state is not validated correctly.
Recommendation — Audit login and callback endpoints for broken authentication handling before issuing tokens.

Key terms

  • Home Realm Discovery: Home realm discovery is the process of identifying which identity provider should authenticate a user before login continues. In enterprise SSO, it usually happens through email domain, tenant context, or routing logic. The security concern is whether that decision is controlled by the backend and aligned with policy.
  • SAML Metadata: SAML metadata is the trusted configuration data exchanged between identity providers and service providers. It describes endpoints, supported protocols, and signing or encryption keys, allowing each side to route assertions correctly and validate trust relationships without manual configuration of every connection detail.
  • Federated Session: An authenticated session issued through an external identity provider and then used to access another platform, such as a cloud provider. It is useful for access control, but it can obscure later identity transitions if new local identities or long-term keys are created during the same activity chain.
  • Tenant Routing Header: A tenant routing header is an HTTP field used to tell a multi-tenant application which customer or virtual domain a request belongs to. It is safe only when the value is strictly validated and never used directly in queries. If mishandled, it can redirect requests across tenant boundaries or alter database context.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on July 6, 2026.
Updated on October 6, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org