When a SaaS product sells to businesses, each customer organisation expects to bring its own identity provider, manage its own users and never see another customer's data, and most consumer-style CIAM designs are not built for that. B2B CIAM adds an organisation layer between the platform and the user: organisations own email domains, enterprise SSO connections, provisioning feeds, roles and administrators. Mistakes in that layer cause cross-tenant access, account takeover through unverified domains and orphaned accounts when a customer's employee leaves. This guide covers the organisation data model, domain verification and routing, per-tenant SSO and SCIM, token claims and tenant isolation, delegated administration and the lifecycle controls that matter. It is for architects and engineers building or buying identity for B2B SaaS.
Key takeaways
- Model the organisation explicitly. Users, domains, connections, roles and admins belong to an organisation object, and one person can belong to several organisations. Do not infer tenancy from email domain alone.
- Verify domains before trusting them. A customer should prove control of a domain (typically with a DNS TXT record) before it can route sign-ins, auto-join users or enforce SSO for that domain.
- Key users by issuer plus subject, not email. OWASP ASVS 5.0 V6.8.1 and V10.5.2 require identities to be namespaced by identity provider so one customer's IdP cannot assert another customer's users.
- Every token and every query carries the tenant. APIs must validate the organisation claim against a known value and filter data by it (ASVS V8.4.1). Missing tenant checks are the root of most cross-tenant leaks.
- Delegated admin is a privileged channel. Customer admins who can change SSO, SCIM and roles hold the keys to that tenant; protect, log and limit them like your own administrators.
How B2B CIAM differs from consumer CIAM and workforce IAM
| Aspect | Consumer CIAM | B2B CIAM | Workforce IAM |
|---|---|---|---|
| Who owns the user | The individual | The customer organisation (often through its own IdP) | The employer |
| Sign-in | Passwords, passkeys, social login | Per-organisation SAML or OIDC SSO, plus local accounts for small customers | Corporate IdP |
| Provisioning | Self-registration | Invitations, just-in-time from SSO, SCIM from the customer | HR-driven |
| Administration | Support team | Customer admins (delegated) plus vendor support | Internal IT |
| Isolation requirement | Per user | Per organisation and per user | Single organisation |
| Leaver handling | User closes account | Customer IdP disables user; SCIM or session expiry must follow | HR leaver event |
For consumer patterns see the Customer IAM (CIAM) Guide. For the data-plane side of tenant isolation see the Multi-Tenant SaaS Authorisation and Tenant Isolation Guide.
The organisation data model
- Organisation: a stable internal ID, display name, plan and settings. Auth0 Organizations, for example, describes each organisation as usually mapping to one business customer or partner, with users able to belong to more than one.
- Membership: a user-to-organisation link carrying roles for that organisation. Keep roles scoped to the membership, not global to the user, so a consultant who is an admin in one customer is a viewer in another.
- Domains: zero or more verified domains per organisation. Keycloak, for instance, forbids the same domain from belonging to two organisations in one realm and supports exact and wildcard domains with the most specific match winning.
- Connections: the identity sources enabled for the organisation: a shared database or passkey connection, social login, or the customer's enterprise SAML or OIDC IdP.
- Managed versus unmanaged members: Keycloak distinguishes members whose accounts exist only through the organisation (managed, removed with it) from accounts that exist independently and were added. Decide which applies, because it controls what happens when membership or the IdP link is removed.
- Application access: whether members can use every application by default or only those explicitly granted. Auth0 calls these the implicit and explicit models.
Domain verification and sign-in routing
Home realm discovery, routing a user to their organisation's IdP from the email domain they type, is convenient and dangerous. If any tenant can claim any domain, an attacker can register a trial organisation, claim a victim company's domain and capture its users' sign-ins or auto-join them.
- Require proof of control: issue a random token and ask the customer to publish it as a DNS TXT record, as in the WorkOS domain verification flow, and only mark the domain verified when you observe it. Re-check periodically and on change of plan or ownership.
- Gate features on verification: only verified domains may enable SSO enforcement, automatic routing, auto-join of new users or the restriction of email domains for members.
- Refuse public mail domains: block consumer webmail domains and public suffixes from being claimed. Keycloak, for example, rejects wildcards over bare top-level domains.
- Handle users with existing credentials: Keycloak does not auto-redirect a user who already has first-factor credentials such as a password; they authenticate with those. Decide your own rule for migrating such users to SSO and communicate it.
- Do not trust the IdP's email blindly: require a verified email before domain-based membership. Keycloak's documentation notes that an OIDC provider returning
email_verified=falsedoes not establish a verified address even when Trust Email is enabled.
Per-tenant SSO and provisioning
| Mechanism | What the customer gets | Security requirement |
|---|---|---|
| SAML 2.0 connection per organisation | SSO from their IdP | Per-tenant entity ID and certificate; signed assertions; audience and recipient checks; reject IdP-initiated flows unless needed. See the SAML Security Guide. |
| OIDC connection per organisation | SSO with modern IdPs | Validate issuer and audience; key accounts on iss plus sub; check acr or amr if you need MFA (ASVS V6.8.4) |
| Just-in-time provisioning | Accounts created at first SSO | Only for verified domains and enabled connections; assign least-privilege default role |
| SCIM 2.0 (RFC 7643, RFC 7644) | Automated create, update and deactivate | Separate SCIM credential per organisation, scoped to that tenant's base path; rotate; log calls. See the SCIM Provisioning Guide. |
| Invitations | Admin invites named users | Single-use, expiring links; invitee must sign in with the invited address (Auth0 enforces this, including for federated sign-in) |
| Local accounts for small customers | No IdP needed | Passkeys or MFA; disable local sign-in once a customer enforces SSO, except for documented break-glass admins |
The cross-IdP spoofing problem: if the application looks users up by email address, a customer who controls their own IdP can assert any email, including one belonging to a user in a different organisation. OWASP ASVS 5.0 V6.8.1 requires that a user's identity cannot be spoofed through another supported IdP, with the standard mitigation being to register users by IdP identifier plus user ID, and V10.5.2 requires the client to identify users by a claim, usually sub, that cannot be reassigned. Store the tuple (connection, issuer, subject), and treat email as a mutable attribute.
Tokens, claims and tenant isolation
- Carry the organisation: put the organisation ID in ID and access tokens. Auth0 includes
org_idby default; Keycloak maps membership through theorganizationscope (which can request one organisation, a named alias, or all memberships) and the Organization Membership mapper. - Validate it: Auth0's guidance is that if an
org_idcannot be validated against a known value, the application or API should deem the token invalid, and that APIs must segment access to data and resources by it. Prefer IDs over names, which can change. - Match the context: check the organisation in the token against the organisation implied by the request (subdomain, path or header). A valid token for organisation A used against organisation B's URL must fail.
- Enforce in the data layer: apply the tenant filter in a shared repository layer, or with database row-level security, rather than in each endpoint. ASVS V8.4.1 asks for cross-tenant controls so operations never affect tenants the consumer is not permitted to touch.
- One active organisation per session: users who belong to several organisations should switch explicitly, and the token should be reissued for the new organisation rather than carrying all memberships into every request.
- Machine clients too: customer API clients and integrations need organisation-scoped client credentials. See the Machine-to-Machine OAuth (Client Credentials) Guide.
Delegated administration
Customers expect a self-service admin console: invite users, assign roles, configure SSO and SCIM, view audit logs. Those powers are equivalent to tenant ownership.
| Admin capability | Risk if abused | Control |
|---|---|---|
| Change SSO connection or certificate | Attacker redirects all sign-ins to an IdP they control (T1484.002 Trust Modification) | Step-up authentication, notification to all tenant admins, optional delay, full audit |
| Issue or rotate SCIM token | Mass account creation or deactivation | Show the token once; store hashed; restrict to admin role; alert on use from new networks |
| Assign admin role | Persistence through extra admins (T1098 Account Manipulation) | Minimum two admins, maximum set by plan, alert on new admin |
| Disable SSO enforcement | Fallback to weaker local sign-in | Step-up and notification; keep break-glass accounts few and named |
| Export users or audit logs | Data exfiltration | Rate limits and logging |
Vendor support access: your own staff impersonating or administering a customer tenant is a T1199 Trusted Relationship path. Require customer-visible, time-boxed, approved access with a reason and log entry, and never let support change SSO or add admins without the customer's consent.
Build admin consoles on the platform's management API from a confidential back end only; Auth0's documentation makes this point for its Management API, and the principle applies to any CIAM platform.
Lifecycle: joiners, leavers and organisation offboarding
- Leavers at the customer: when the customer's IdP disables a user, SSO stops new sign-ins but existing sessions, refresh tokens and API keys in your product survive. Accept SCIM deactivation, shorten session and refresh lifetimes for SSO users, and support back-channel logout or Shared Signals events where you can. See the Shared Signals Framework Guide.
- Personal tokens: revoke API tokens a user created when their membership ends; SCIM deactivation does not do this unless you wire it.
- Movers between organisations: a consultant leaving one customer keeps their memberships elsewhere; remove only the affected membership.
- Organisation offboarding: on contract end, disable connections, revoke SCIM and API credentials, end sessions, then delete or retain data according to contract and privacy obligations.
- Domain transfer: when a company is acquired or a domain changes hands, re-verify and move domains deliberately rather than letting two organisations claim the same users.
Choosing an approach
| Situation | Approach |
|---|---|
| Early-stage SaaS, mostly small customers | Shared login with organisation membership, passkeys or MFA, invitations; add SSO per organisation when the first enterprise asks |
| Mid-market with many SSO customers | CIAM platform with native organisation support, self-service SSO and SCIM setup gated on domain verification |
| Large enterprise customers with strict isolation demands | Organisation model plus dedicated signing keys or even a dedicated CIAM tenant per customer; note that some platforms (Auth0 among them) do not support per-organisation custom domains, so separate domains require separate tenants |
| Partners and resellers administering their customers | Hierarchical organisations or explicit cross-organisation roles with audit, never shared admin accounts |
| Workforce collaboration between two Microsoft tenants | Not a CIAM problem; see the Entra ID Cross-Tenant Access and B2B Guest Governance Guide |
How to implement
- Define the model: organisation, membership, roles, domains, connections, and managed or unmanaged accounts. Write down which identifier is canonical (connection plus issuer plus subject).
- Add domain verification: DNS TXT verification, public domain block list, periodic re-check.
- Thread the tenant through: organisation ID in tokens, validation middleware in every API, tenant filter in the data layer, and automated tests that try cross-tenant access for every endpoint.
- Self-service SSO and SCIM: enable for verified organisations, with per-tenant credentials and test-connection steps before enforcement.
- Delegated admin with guard rails: step-up for sensitive changes, notifications, audit log visible to the customer.
- Pilot with friendly customers: migrate two or three organisations to SSO enforcement, keep a break-glass local admin, and measure sign-in failures.
- Rollback: allow a tenant admin, or your support team with recorded customer approval, to switch enforcement off temporarily while keeping SSO configured.
Detection and measurement
- Log per tenant: sign-ins by connection, SSO and SCIM configuration changes, admin role grants, domain verification events, support access sessions and cross-tenant authorisation failures.
- Alert on: a new SSO certificate or IdP URL followed by a spike in new accounts; claims of high-profile or already-claimed domains; tokens with an organisation ID that does not match the request context; SCIM calls from new networks.
| Metric | Healthy signal |
|---|---|
| Share of SSO-capable organisations with a verified domain | 100% |
| Cross-tenant test coverage of API endpoints | Every endpoint covered in CI |
| Cross-tenant authorisation failures in production | Rare, each investigated |
| SCIM-enabled organisations among SSO organisations | Rising |
| Median time from customer IdP disable to session end | Minutes, not days |
| Support access sessions without a recorded approval | Zero |
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| OWASP ASVS 5.0 | V6.8.1, V6.8.4, V7.1.3, V8.4.1, V10.5.2 | IdP namespacing, authentication strength from the IdP, federated session coordination, cross-tenant controls, stable subject |
| NIST SP 800-53 Rev. 5 | AC-2, AC-3, AC-6, IA-4, IA-8, PS-4, SA-9 | Accounts, enforcement, least privilege, identifiers, non-organisational users, termination, external services |
| NIST CSF 2.0 | PR.AA-01, PR.AA-05, GV.SC-07 | Identity management, least privilege, third-party relationships |
| ISO/IEC 27001:2022 Annex A | A.5.15 Access control, A.5.16 Identity management, A.5.18 Access rights | Policy and lifecycle for customer identities |
| MITRE ATT&CK v20 | T1199, T1484.002, T1098, T1078.004, T1136.003 | Trusted relationship abuse, trust modification, admin persistence, cloud account misuse and creation |
Common failure patterns
- Unverified domain claims: any trial tenant can claim a domain and capture routing or auto-join for that company's users.
- Email as the primary key: a customer IdP asserts another tenant's user's email and is signed in as them, the failure ASVS V6.8.1 exists to prevent.
- Tenant from the URL only: the API trusts the subdomain and ignores the organisation in the token, or the reverse, so a token for one tenant reads another.
- Global roles: admin in one organisation becomes admin everywhere because roles are stored on the user, not the membership.
- SSO without deprovisioning: customer leavers keep refresh tokens and API keys for months because SCIM was never enabled.
- Silent SSO changes: a compromised customer admin swaps the IdP certificate and nobody else in the tenant is told. Compare the federation trust abuse patterns in the Golden SAML and Federation Trust Abuse Defence Guide.
Practitioner checklist
- Model organisation, membership-scoped roles, domains and connections explicitly.
- Verify domains by DNS before enabling routing, auto-join or SSO enforcement; block public mail domains.
- Store users by connection, issuer and subject; treat email as an attribute.
- Put the organisation ID in tokens and reject tokens whose organisation is unknown or does not match the request.
- Enforce the tenant filter in a shared data layer and test cross-tenant access for every endpoint in CI.
- Issue a separate, rotatable SCIM credential per organisation.
- Require step-up, notification and audit for SSO, SCIM and admin role changes.
- Make vendor support access approved, time-boxed and visible to the customer.
- Revoke sessions, refresh tokens and personal API tokens on SCIM deactivation and membership removal.
Standards and references
- OWASP: Application Security Verification Standard 5.0
- IETF: RFC 7644 System for Cross-domain Identity Management: Protocol
- NIST: SP 800-53 Rev. 5
- Auth0: Organizations overview
- Auth0: Work with tokens and Organizations
- Keycloak: Server Administration Guide, Managing organizations
- WorkOS: Domain verification
Related NHI Mgmt Group resources: Customer IAM (CIAM) Guide · Multi-Tenant SaaS Architecture Security Guide · SCIM Provisioning Guide · CIAM Buyer's Guide