How to handle multi-tenant authentication for a B2B SaaS, with white-label login for every customer
Multi-tenant authentication for a B2B SaaS is handled by modelling each corporate customer as an isolated tenant, with its own user base, its own security policies, its own SSO federation to the customer's identity provider and its own branding on the login pages. Six decisions matter, they are taken before writing code, and the most expensive one to change later is the first: whether a user is a single platform-wide entity belonging to several tenants, or whether each tenant has a separate user base.
Step 1 — The identity model: the irreversible decision
The concrete question is this: if Jane works for customer A and is also invited by customer B with the same email address, is she one person or two?
| Model | How it works | Strengths | Hidden costs |
|---|---|---|---|
| Per-tenant user base | Each tenant has its own users; the same email in two tenants means two distinct accounts | Maximum isolation, trivial customer deletion, no correlation between customers | Anyone working with several customers manages several credentials and switches context by logging out |
| Single identity, multiple membership | The user is unique platform-wide and holds roles in several tenants | Smooth experience for consultants, partners and shared users | Deleting a customer cannot delete the user; you need an explicit membership model |
| Hybrid | Single identity for internal users and partners, separate base for each customer's end users | Covers the real scenario of most B2B SaaS products | Requires the platform to distinguish user types within the same tenant |
The choice should be made looking at the sales model, not the data model: if you sell to large companies bringing their own employees, a separate base per tenant is almost always right; if your product is used by agencies and consultants working for several clients, rigid separation becomes a recurring complaint by month three.
Step 2 — How the tenant is resolved at login
Before authenticating you need to know in which context you are authenticating: it decides which branding to show, which policy to apply and which identity provider to route to.
| Strategy | Example | Pros | Cons |
|---|---|---|---|
| Subdomain | acme.yourapp.com | Tenant known before login, immediate branding, easy to automate | Requires wildcard DNS and certificate |
| Custom domain | login.acme.com | Maximum white-label effect, the user never leaves the customer domain | Per-customer DNS and certificate onboarding, to be automated |
| Email domain (home realm discovery) | jane@acme.com → Acme tenant | A single entry point, excellent with federated SSO | Shared domains (gmail.com) need separate handling |
| Explicit selector | The user picks the organisation after login | Native for multiple membership | Branding only possible after the choice |
| Application parameter | The tenant is in the invitation link | No extra infrastructure | Fragile: shared links and bookmarks land in the wrong tenant |
In practice mature SaaS products combine two: subdomain or custom domain for branding, and home realm discovery on the email domain to route federated users to the correct IdP.
Step 3 — Per-customer federated SSO
The first enterprise customer signing a meaningful contract will ask for SSO with their own Entra ID. The second uses Google Workspace. The third has Okta and a SAML 2.0 requirement. If federation is configured globally rather than per tenant, every new customer becomes a development project.
- Identity provider configuration (client ID, secret or certificate, metadata, claim mapping) must belong to the tenant.
- Group → role mapping differs per customer: 'GRP-ADMIN' at Acme and 'admins@beta.com' at Beta must be able to point to the same application role.
- Federated users and local-credential users must coexist in the same tenant: almost every customer has at least one external consultant outside their directory.
- Deprovisioning follows the customer directory: when their IdP disables the user, access to your SaaS stops without a ticket to your support.
The full federation procedure for Entra ID and Google Workspace, with endpoints, claims and typical errors, is in the dedicated SAML 2.0 and OIDC SSO guide.
Step 4 — White-label: what must really be customisable
"White-label" used as a synonym for "you can upload a logo" is the most frequent cause of renegotiation with an enterprise customer. The list of what the end user sees, and which must therefore be able to belong to the customer, is longer than it looks.
| Touchpoint | Why it matters | Minimum acceptable level |
|---|---|---|
| Login page | It is the first impression of the service | Logo, colours, fonts, layout |
| Domain | A redirect to a third-party domain creates distrust and tickets | Customer subdomain or domain |
| Verification and welcome emails | They land in inboxes and get forwarded to colleagues | Sender, subject, template, language |
| Password reset | By far the most used flow after login | Custom page and email |
| 2FA setup | Perceived as part of the customer's product | Custom page on the tenant domain |
| Active session management | Requested by customer security teams | Custom page |
| Error messages | An English error inside a localised product breaks the illusion | Per-tenant localisation |
In LoginMaster no vendor reference appears in the production user experience, and customisation extends to email templates, domain and identity management pages, with different templates per language and user type. Details on white-label authentication.
Step 5 — Isolation: logical or cryptographic
Nearly every platform claims tenant isolation. The question that discriminates is: is isolation guaranteed by an application check — a WHERE tenant_id = ? clause and a claim in the token — or by a cryptographic property?
The difference shows in one scenario only, but it is the one that counts: a bug in a query, an unverified claim, a manipulable parameter. With application-level isolation that bug is a cross-customer data breach. With cryptographic isolation, validation fails structurally because the token is not signed with that tenant's keys.
POST /v1/auth/verify HTTP/1.1
Host: api.loginmaster.it
X-Project-Key: pk_live_••••••••
Content-Type: application/json
{ "token": "lm2f.eyJhbGciOiJFZERTQS..." }
HTTP/1.1 200 OK
{
"valid": true,
"subject": "sub_9f2a7c",
"tenant": "https://acme.example.com",
"signatures": { "tenant": "verified", "cloud": "verified" }
}Every tenant has its own cryptographic identity and every project its own key: a token issued for tenant Acme, presented in the context of tenant Beta, does not fail a check — it fails signature verification. It is the same property that makes it sustainable to host mutually competing customers on the same platform, which is the norm in a vertical SaaS.
Step 6 — Onboarding a new customer via API
If creating a tenant requires a person, the marginal cost of a customer never goes down. Onboarding must be a sequence of API calls your back-office or a self-service flow can run.
- 1Create the tenant and set baseline policies (session lifetime, password requirements, allowed second-factor types, authorised email domains).
- 2Register the projects: web application, mobile app, optional customer admin panel, each with its own 2FA policy.
- 3Apply branding: logo, palette, email templates, default language.
- 4Configure federation, if the customer brings their own identity provider.
- 5Provision the initial users and subscribe to webhooks to keep application state in sync.
POST /v1/projects/prj_12ab/subjects HTTP/1.1
Host: api.loginmaster.it
Authorization: Bearer ak_live_••••••••
Content-Type: application/json
{
"type": "user",
"externalId": "acme-4821",
"roles": ["member"]
}The full lifecycle, including role change and deactivation, is in User provisioning and lifecycle via REST API and SDK.
Build, self-host or platform: the comparison
There are four real options for a B2B SaaS. None is wrong in the absolute: what changes is when the cost shows up and who pays it.
| Option | Where it works well | Where it breaks |
|---|---|---|
| Build in house | Young product, simple tenants, no enterprise requirements | At the first customer asking for SAML SSO, audit logs and white-label on their own domain |
| Self-hosted open source IdP (e.g. Keycloak, one realm per customer) | Full control, no licence cost, in-house skills available | Operational staffing, major upgrades, performance and management with many dozens of realms |
| Specialised B2B platforms | Fast time to market on organisation and invitation features | Per-active-user cost, data jurisdiction, limits on deep branding |
| Generalist platforms with a multi-tenant extension | Wide ecosystem, many ready integrations | Multi-tenancy is a bolted-on layer: logical isolation, costs growing with users |
| Criterion | Question to ask during selection |
|---|---|
| Isolation | Is tenant isolation application-level or cryptographic? Can one tenant's token be technically valid in another? |
| Pricing | Does cost depend on monthly active users? What happens to the margin when a customer brings 20,000 users? |
| White-label | Can I use the customer's domain, their email templates and no vendor reference? |
| Per-tenant SSO | Can each customer bring their own IdP without development work on my side? |
| Administrator powers | Can one of your administrators, or one of mine, reset an end user's password? |
| Data and jurisdiction | Where does personal data live and who has technical access to it? |
| Audit and SIEM | Are per-tenant events exportable to the customer's SIEM? |
| Exit | How do I export users and configurations if I decide to move? |
The pricing point, which in B2B is architectural
In a B2B SaaS you do not decide the number of end users: your customer does. An authentication model priced per active user means a contract won with a 30,000-employee customer carries a variable cost that erodes the margin of that contract exactly when it should improve it. LoginMaster bills per tenant and per project, with users always unlimited and included: authentication cost stays predictable while your customers grow. The model is described on pricing.
Do you need CIAM or IAM?
Anyone evaluating platforms for a multi-tenant B2B SaaS meets both acronyms. IAM in the strict sense governs workforce identities: employees, corporate SSO, lifecycle, internal access. CIAM governs customer identities: self-service registration, white-label login, far higher volumes and attention to experience. A B2B SaaS needs both, because its users are employees of customer companies: identities with CIAM requirements for scale and branding, but governed by the customer's workforce policies.
That is why the same platform must cover both worlds in the same tenant, with distinct policies and branding per user type: the CIAM and IAM for B2B SaaS pages cover the two sides.
Where this guide comes from
LoginMaster is the IAM platform of CDBKR S.r.l., an Italian company providing authentication infrastructure to software houses and MSPs that resell their product to corporate customers. The tenant concept, the cryptographic isolation and the white-label described here are the architectural constraints the product is built on, not features added later: Security covers the detail, the case studies show a real adoption and the partner programme the model for resellers. To discuss your own scenario: contact us.
Frequently asked questions
By modelling every corporate customer as an isolated tenant, with its own user base, security policies, SSO federation and branding. The six decisions to take before writing code are: the identity model (single user with multiple membership, or a separate base per tenant), the tenant resolution strategy at login, per-customer configurable SSO federation, the extent of white-label, the isolation level between tenants and the automation of onboarding via API.
It depends on the model you choose, and it must be decided upfront. With a separate user base per tenant they are two distinct accounts with the same email: maximum isolation, but the user manages two credentials. With single identity and multiple membership it is one person holding roles in two tenants: smoother experience, but deleting one customer's data cannot delete the user. The hybrid model — single identity for partners and consultants, separate base for each customer's end users — is what covers most real B2B SaaS products.
Branding must be a property of the tenant, not a global setting. In LoginMaster every tenant customises login, password recovery, second-factor and session management pages, email templates, sender, language and domain: no vendor reference appears in the production experience. The recommended combination is the customer's custom domain plus email templates with their sender, because the domain and the inbox are the two places where the end user notices a third-party vendor.
Yes, and it is the requirement that arrives punctually with the first enterprise contract. Identity provider configuration must belong to the tenant: client ID, certificate or metadata, claim mapping and the translation of groups into application roles differ for every customer. Federated users and local-credential users must coexist in the same tenant, because almost every customer has external consultants outside their directory.
Logical isolation separates data with a tenant identifier in queries and tokens: it works as long as every code path applies the filter correctly. Cryptographic isolation gives each tenant its own keys, so a token issued for tenant A cannot technically be validated in the context of tenant B. In LoginMaster tokens carry two independent signatures, tenant and cloud: the difference matters in the only scenario that really counts, when an application bug bypasses the filter.
Far more than it seems, because the number of end users is decided by the customer, not by you. With a per-monthly-active-user cost, a contract won with a 30,000-employee customer carries a variable cost that erodes the margin of your best contract. LoginMaster bills per tenant and per project, with users always unlimited and included: it is why software houses and MSPs reselling to several customers find authentication cost predictable regardless of how their customers grow.
Both, because the users of a B2B SaaS are employees of customer companies: they carry CIAM requirements for scale, registration and branding, but they are governed by their employer's workforce policies. The platform must therefore cover both worlds in the same tenant, with distinct policies and branding per user type, instead of forcing you to run two separate systems and reconcile them.
It is the norm in a vertical SaaS, and exactly the scenario where the isolation level becomes a contractual rather than technical question. With cryptographic isolation per tenant and dedicated per-project keys, a breach affecting one tenant's credentials has no impact surface on the others, and the answer to the customer's security questionnaire is a documentable property of the architecture rather than a statement of intent.
Want to see LoginMaster in action?
Request a personalized demo and discover how to manage identities and access securely and compliantly.