Keycloak Organizations for B2B multi-tenancy

Keycloak Organizations let you manage business customers inside one realm. This guide covers domains, member onboarding, per-organization identity providers and the cases where separate realms are the safer choice.

On this page

How Keycloak Organizations support B2B multi-tenancy in one realm

A SaaS or platform team serving many business customers has to decide how to separate their users and sign-in. The Keycloak Organizations feature lets you group members, email domains and identity providers for each customer inside one realm, so you can keep a single set of clients and a single user store while still scoping sign-in to each business. That grouping is the core idea, but it is harder to get right than the feature name suggests.

The difficulty comes from what you share. Every organization uses the same clients, so redirect URIs, scopes, token claims and client settings apply to all customers at once, and a change made for one customer affects all of them. The user store is also shared, so a user's identity is one record that may belong to more than one organization, and you need a clear rule for how membership, roles and attributes are read. Admin delegation adds another layer: deciding which customer administrators can manage their own members without seeing other organizations' data requires you to confirm what the admin console and Administration REST API permit at the exact release you deploy.

Before you commit, confirm the behavior of each Organizations setting against the Keycloak server administration guide for your target version, and test domain verification, invitation flows, per-organization identity providers and token contents in a non-production realm. Ask your team to write down which of these behaviors your customers' security reviews will depend on, because those are the ones to verify first.

Which Keycloak Organizations settings carry B2B multi-tenancy

Keycloak Organizations for B2B multi-tenancy depends on a small set of linked settings: the organization record, its domains, its members, its identity providers, the realm and clients underneath, and the administrators who manage them. Each one controls a different part of who can sign in, where, and with what level of control, so review them together before onboarding the first business customer.

Organization record

The organization record is the tenant object itself: its name, its alias and its attributes. Everything else in this model hangs off it, so the record is the first place to check when a customer's users land in the wrong tenant. Decide early how organizations are named and whether you need custom attributes such as contract tier or support contact, because renaming or restructuring later touches every linked domain, member and provider. Confirm in your Keycloak version where organizations are created in the admin console under the realm's Organizations area.

Keycloak server admin guide

Organization domains

Domains tell Keycloak which email addresses belong to which organization, so a user typing a corporate address can be routed to the right sign-in path. A domain claimed by two organizations, or a typo in a domain, creates misrouted logins that look like outages to the customer. Check domain ownership for each customer before you add it, and decide whether unmatched domains should fall back to the realm's standard login. Domain settings are on each organization's detail page in the admin console.

Organization members

Members link realm users to an organization. Membership is what lets an organization-scoped login apply, and it is also what an administrator removes when a customer leaves. Decide who creates members: your team by invitation, the customer's administrator, or a federated directory feed. Each choice changes how fast access is granted and revoked, so test offboarding as carefully as onboarding. Member lists are managed per organization in the admin console.

Linked identity providers

An identity provider linked to an organization lets that customer's users sign in through their own OIDC or SAML provider instead of a local password. Each provider needs its own redirect settings, attribute mappings and first-login behavior, so a misconfigured one affects only that tenant but can block all of its users. Test the full sign-in path with a pilot account before go-live, and record which provider belongs to which organization. Provider links are set from the organization's identity provider section.

Realm and clients

Organizations live inside one realm, so the realm's clients, authentication flows, password policy and session lifetimes apply to every tenant unless you change them. A client that does not require organization context can let users from any tenant reach an application, which is a common gap in shared-realm designs. Review which clients use organization scope and which do not, and confirm that token claims carry the organization information your application needs. Realm settings and client scopes are in the admin console under the realm.

Administration roles

Administrators who manage organizations need rights limited to their own tenant, or one customer's administrator can change another customer's settings. Keycloak's realm roles and client roles control who can manage organizations, so map them to your support and customer-success teams deliberately rather than granting full realm admin. Confirm the exact role names and permissions in your release, since this area changes between versions. Audit these grants on a schedule, because they are easy to over-assign during early rollout.

One realm with Organizations or separate realms for B2B multi-tenancy

This table compares three ways to host business customers in Keycloak: one realm with Organizations, one realm per customer, and a hybrid. Read each row as an operational cost you will carry after go-live, then check the decision criteria in your own environment before choosing.

DimensionOne realm with OrganizationsOne realm per customerHybrid: shared realm plus dedicated realms for large or regulated customers
When it fitsMany customers with similar sign-in rules, shared applications, and a small platform teamCustomers need strict isolation, separate admin authority, or distinct protocol settingsA shared base for most customers, with a few customers whose requirements justify their own realm
User storeShared user pool; membership links users to organizationsIsolated user store per customer; no cross-customer visibilityShared for most customers; isolated for the dedicated realms
Admin delegationOrganization admins are scoped within the realm; confirm which actions they can perform in your versionEach realm has its own administrators, which simplifies delegation but multiplies admin accountsCentral team administers the shared realm; each dedicated realm is delegated separately
Client configurationApplications are defined once and shared, so changes apply to all customers at onceClients are duplicated per realm, so each change is repeated and can driftShared clients for most customers; duplicated clients only in dedicated realms
Upgrade and testing effortOne realm to test per release, but a configuration error affects every customerTest effort grows with each realm; automation is needed to keep realms consistentTwo test paths to maintain; dedicated realms need their own regression checks
Branding and login policyPer-organization branding and policy depend on what your version supports; confirm before designFull control over themes, flows, and password or MFA policy per realmShared theme for most customers; full control for dedicated realms
Per-customer identity providerOrganization-linked identity providers are possible; confirm domain and first-login behavior in your versionIdentity providers are configured per realm without shared dependenciesShared brokering for most customers; dedicated providers in dedicated realms
Operational cost to watchMembership and domain changes must be governed, or access drifts over timeRealm count drives backup, monitoring, and upgrade workClear rules for when a customer moves to a dedicated realm must be written down

How a member signs in through an organization

The flow starts when a user enters an email address on the sign-in page of a client application that uses the realm. Keycloak checks the email domain against the domains registered on the realm's organizations. If a match exists, Keycloak routes the user to that organization's identity provider when one is configured, or to the local login otherwise. Keycloak then returns tokens to the client application. Check that the admin console runs on a separate hostname from the public sign-in endpoint, since only the public side should be reachable by members.

Domain matching routes a member to an organization identity provider or local login.

Building B2B multi-tenancy in one Keycloak realm, step by step

This sequence takes one Keycloak realm from a strategy decision to a tested setup where two business customers each have their own domains, members, identity provider and isolated access to shared applications.

  1. Confirm the realm strategy first

    Before creating anything, the architecture owner and identity lead agree that the business customers will share one realm, and they list the attributes that must differ per customer, such as sign-in provider, branding and member administration. Write down which applications the customers will use and whether any customer needs its own user store, password policy or MFA rule, because those needs are the usual reasons to choose separate realms instead. The step is done when the decision and its reasons are signed off in writing. Confirm with your own requirements review that the Organizations feature covers each listed need in the Keycloak release you plan to run, using the Keycloak server administration guide.

  2. Enable and create the first organization

    An administrator enables the Organizations feature in the test realm and creates the first organization with a name and an alias that matches your naming convention. Keep the organization's name as a business label and avoid tying it to a single person or project. The check is that the organization appears in the admin console and that its details can be opened and edited. If the feature is not visible, confirm how it is enabled for your exact release, because the enablement method is release-specific and should be checked against the administration guide rather than assumed.

  3. Register and verify organization domains

    Add the email domains that belong to the customer, for example the domain used by its staff, and complete any verification step the release requires for those domains. Domain registration is what lets Keycloak associate a sign-in with the correct organization, so a wrong or unverified domain causes users to land in the wrong place or not be recognized at all. The check is a test sign-in attempt with an address on each registered domain, confirming it is routed to the intended organization, and an address on an unregistered domain, confirming it is not. Record the domain owner so changes can be reviewed later.

  4. Define the member onboarding path

    Decide how members join each organization: an administrator or organization owner sends an invitation, or users self-register against an allowed domain, depending on what your release supports and what your customer agreements require. Document who may approve a new member and what happens when a person leaves the customer. Test each path with a dummy account: send an invitation, accept it, and confirm the user appears as a member of the correct organization only. The check is a membership list that matches the test accounts exactly, with no user attached to a second organization by accident.

  5. Attach a per-organization identity provider

    For a customer that uses its own corporate identity provider, add an OpenID Connect or SAML 2.0 identity provider and link it to that organization only. Configure the first-login flow so that new federated users are created or linked as intended, and map the claims or attributes the applications need, such as a role or department, into Keycloak user attributes. Confirm the redirect URIs and certificates with the customer's identity team before testing. The check is a successful sign-in through the customer's provider, with the expected attributes visible on the user and no access granted to users from other organizations' domains.

  6. Connect the client applications

    Register each client application in the realm and confirm that it passes the organization context it needs to the application, either through the token claims or through the sign-in parameters your release supports. Decide whether each application should accept any member of any organization or only members of specific organizations, and enforce that decision in the application or in mapped roles rather than assuming the realm enforces it. The check is that a token issued for a member of one organization contains only the claims that organization should produce, and that the application rejects a session without the expected organization context.

  7. Test with two organizations to prove isolation

    Create a second organization with its own domain, members and identity provider, then run the same sign-in and access tests for both. Include negative cases: a member of organization A must not see organization B's members, must not sign in through B's identity provider, and must not reach resources restricted to B in the connected applications. Repeat the tests after any change to the realm. The sequence is complete when every test case has a recorded result, every failure has a fix or an accepted risk signed by the owner, and the configuration has been exported for review before any production realm is created.

How the setup changes by identity source

When members exist only as users in the realm, the organization is mostly a grouping and access boundary. You create the organization, attach its domains, invite or onboard members, and assign them roles in the client applications. Keycloak holds the credentials, so password policy, MFA, and account recovery are all managed in the realm itself, and the organization setup adds no separate sign-in path.

  • Account ownership: Confirm who creates and removes local accounts, since the business customer's administrators may expect to manage their own staff.
  • Credential policy: Verify that the realm password policy, OTP or passkey requirements, and brute force settings apply equally to every organization.
  • Invitation flow: Test the onboarding email path end to end, including SMTP configuration, because the invite depends on it.
  • Offboarding: Check that disabling a member in one organization does not affect the same person's access elsewhere in the realm.
  • Support load: Ask who resets passwords for these members, because no upstream directory will do it.

Check that every local member can complete sign-in, password reset, and removal from the organization without involving your platform team.

What drives the cost of B2B multi-tenancy on Keycloak

This table lists the main drivers of effort for running business customers as organizations in one Keycloak realm, with the one-time and recurring work each driver creates. Read each row as a lever: the first column names the driver, and the other columns show how it adds effort and how to keep it contained. No hours or prices are given because they depend on the written scope.

DriverWhy it changes effortHow to keep it downOne-time or recurring
Number of organizationsEach organization adds configuration for its domains, members, and any identity provider, so volume multiplies onboarding and admin work.Automate organization creation from your customer system of record and avoid hand-built setup per customer.Onboarding is recurring; the automation design is one-time
Members per organizationLarge member lists raise invitation volume, support requests for lost access, and the review needed when people leave a customer.Use self-service invitations where your policy allows, and set a clear owner for each organization to approve members.Recurring
Number of identity providersEach per-organization identity provider needs its own trust setup, attribute mapping, first-login flow, and testing when the customer's provider changes.Standardize on a small set of protocols and mapping templates, and confirm which customers truly need their own provider.Setup is one-time per provider; changes to customer providers are recurring
Domain verification workDomains must be proven before a customer's users are routed to the organization, and each customer's DNS changes need follow-up.Collect domain ownership proof during contract signing and keep a record of who verifies each domain.Verification is one-time per domain; re-checks recur
Client applications honoring organization claimsEach application must read organization data from tokens and enforce tenant boundaries, which often means code changes in several services.Agree one claim format across applications early, and test tenant isolation in each application before rollout.Build is one-time; changes to claim handling recur with each new application
EnvironmentsEach environment needs its own organizations, identity providers, and test customers, so configuration must be copied and kept in step.Export and import realm configuration from source control and limit manual edits in production.Setup is one-time; keeping environments aligned is recurring
Per-tenant login customizationBranding or custom flows for one customer add theme variants and extra testing for each change made to shared login pages.Limit branding to a small set of themes, and keep custom flows shared unless a customer contract requires otherwise.Design and build are one-time; theme updates recur with each Keycloak upgrade
Compliance evidenceAssessors and customer security reviews may ask how each tenant's access, logs, and admin actions are controlled, which means collecting records per organization.Define the evidence list before build, and set up audit event reporting that can be filtered by organization.Evidence design is one-time; collection and review are recurring
Admin delegationDelegating organization administration to customer staff or internal teams needs role design, approval steps, and periodic access reviews.Use a small number of standard admin roles and document who may approve changes for each organization.Role design is one-time; access reviews recur

How to test tenant isolation and failure paths

Test tenant isolation before any business customer signs in, because an Organizations setup that looks correct in the admin console can still leak data across members. Build the test plan around four claims. A member of organization A must not reach organization B's data, applications or admin functions, even when they know the URL of another client. Domain routing must send each email address to the correct sign-in, including look-alike domains and addresses that match no organization. A member removed from an organization must lose access to every client that organization grants, and existing sessions and refresh tokens must stop working within the lifetime you have set. Finally, when an organization's external identity provider is unavailable, sign-in for that organization must fail with a clear message while other organizations and local users keep working. Each claim needs a named test case, an expected result and an owner.

Run these cases in a non-production realm that mirrors production settings: the same client definitions, authentication flows, token lifetimes and brokered identity provider types, with two or three test organizations and a dedicated test member in each. Script the cases where you can, using the Administration REST API with separate admin accounts, and repeat the full set after every configuration change and every Keycloak upgrade. Include negative tests such as a member of organization A replaying a session cookie against organization B's client, an unlisted domain on a valid member account, and a deliberately wrong identity provider metadata value to confirm the failure page reveals no other organization's name or configuration. Check the event log and admin events for each step so audit output is verified, not assumed.

Record each run as evidence: the Keycloak version, the realm export or configuration hash, the test accounts used, the timestamp, the expected and actual result, and the reviewer's sign-off. Store the results with the change record so security reviewers and auditors can see what was tested and when. Confirm with your security team which failure outcomes they accept, such as whether an unavailable identity provider may show a generic error or must redirect to a support page, and whether test data must be deleted after each run. Plan for the retest after any fix, and treat any cross-tenant access as a release blocker rather than a known issue to track.

Keeping one customer's members out of another customer's tenant

A single realm with Organizations puts many business customers behind one identity server, so isolation depends on configuration rather than on separate databases or realms. The cards below cover the controls that keep one organization's members, admins, identity providers and credentials out of another organization's view, and the checks to run before go-live.

Limit what tokens reveal about membership

Client scopes and protocol mappers decide which organization claims reach each application. An application for one customer should receive only the organization context it needs, not a list of every organization in the realm. Review the default client scopes on each client and remove mappers that expose membership to applications that do not need it. Test with a token from a member of one organization and confirm no other organization's name, ID or domain appears.

Keycloak docs

Scope administrators to one organization

Organization-level administration is only safe if an administrator who manages one customer cannot change another customer's members, domains or identity providers. Map realm-level roles narrowly and avoid granting the realm admin role to customer-facing staff. Confirm in a test realm that an organization administrator receives a permission error when attempting to edit a different organization. Record who holds each role and review the list on a fixed schedule.

Separate the admin hostname from public endpoints

The production guide advises exposing the admin console and Administration REST API on a different hostname or context path from public frontend URLs. Because every organization shares this surface, a single exposed admin path affects all customers at once. Confirm that the reverse proxy blocks admin paths on the public hostname and that the admin hostname is reachable only from administrator networks.

Production guide

Enforce TLS on all traffic

Keycloak's production guide calls for TLS on all communication. For a shared realm this includes database connections, traffic between nodes, and calls to external identity providers configured per organization. Plaintext in any hop can expose tokens or member data from several customers at once. Verify certificates on each identity provider endpoint and confirm the database connection uses encryption.

Audit membership and identity provider changes

Changes to organization membership, domains and identity providers alter who can sign in to a customer's tenant, so they need a trail. Enable admin events and review who added a member, changed a domain or edited a provider mapping. Ask each customer which changes they expect to be notified about and confirm the audit trail can answer a question about a specific organization within a reasonable time. Keep retention aligned with the client's own policy.

Protect per-organization client secrets and provider credentials

Each organization may bring its own identity provider client secret, and applications may hold client secrets scoped to one customer. A leaked secret from one organization can allow sign-in impersonation within that tenant. Store these values in a secrets manager, rotate them on a schedule agreed with the customer, and restrict which administrators can view them. Ask whether the Keycloak version in use masks secret values in the admin console and what the rotation procedure requires.

Keeping organization records current after go-live

The team that runs a multi-tenant Keycloak realm has to keep organization records accurate after go-live, because stale membership, domain or identity provider data is where tenant isolation quietly breaks. Start by writing down four recurring procedures and assigning an owner to each: member offboarding, domain changes, identity provider credential rotation and review of organization administrators. Offboarding deserves the most attention. Removing a person from a customer's organization is not the same as disabling their account in the realm, and a leaver's organization membership, active sessions and any organization-scoped roles should all be checked. Ask the customer's administrator to confirm departures on a set schedule, and agree in writing who on your side acts on those requests and how fast.

Domain changes and identity provider rotation are the two events most likely to route users to the wrong place. When a customer changes its email domain, the old and new domains must be reviewed together before anyone changes the organization's domain list, because a domain claimed by two organizations, or left attached to a retired one, can send sign-ins to the wrong identity provider. For each organization's identity provider, track certificate expiry and metadata versions for SAML and endpoint and key details for OIDC, and confirm with the customer's IT team before any change. Review organization administrator accounts on the same cadence, since these people can change member and provider settings without realm administrator involvement.

Backups and documentation close the loop. A realm backup taken with only user data does not capture organization definitions, domain claims or per-organization provider settings, so confirm with your backup tooling and a restore test in a non-production environment that these are included. Keep a tenant record for each organization covering its domains, providers, administrators, named contacts and the date of its last review. Upgrades change this picture: read the Keycloak upgrading guide for every minor release, and if you run the Operator, keep manual approval mode so you review each update before it reaches production. The upgrades sibling topic covers the full process, including testing realms before rollout.

Questions buyers ask before building B2B multi-tenancy on Keycloak

Should we use one Keycloak realm or many realms for B2B customers?

For most B2B products with many business customers that share the same applications and login policies, one realm with Organizations is the better default. Organizations give each customer a membership boundary, a domain, and optionally its own identity provider, without the cost of running and synchronizing a separate realm per customer. Separate realms are usually the better choice when customers need different password policies, different token lifetimes, separate administrators who must not see each other's configuration, or hard isolation for regulatory reasons. Ask your security and compliance leads to confirm which isolation boundary they expect before you design anything, because moving a customer between realms later is more work than changing a membership.

How much internal time does a Keycloak Organizations rollout need?

Internal time depends mostly on how many applications must honor organization membership, how many customers will bring their own identity provider, and whether you already have a Keycloak environment with HA, backups and a release process. The work splits into design of the realm model and claims, changes in each application, testing of sign-in and admin flows, and operating the admin process for onboarding customers. Identity engineers, application owners and a security reviewer usually all spend time, and that time recurs when new customers or applications are added. The implementation plan for a self-managed Keycloak rollout covers how to size these roles and budget them.

Can our team build multi-tenancy on Keycloak without a partner?

A team with working Keycloak experience can build Organizations without outside help, provided it has someone who understands OpenID Connect token design, someone who owns each application's authorization logic, and time to test failure cases such as users who belong to two organizations or a customer whose identity provider changes. The common gaps are not the Keycloak configuration itself but the application changes, the onboarding runbook, and the evidence a security review will ask for. Confirm internally whether those skills and hours are available before you decide, and compare the result with the cost of ownership guidance for building and running the platform yourself.

What does a fixed-scope DeployOpen engagement cover for Keycloak Organizations?

Most DeployOpen engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. For an Organizations project, the written scope typically names the target environment, the realm model decision, the applications that will consume organization claims, the identity providers to be brokered per organization, the onboarding process to be documented, and the testing and handover items. Work can include deploying or hardening the Keycloak instance inside your own infrastructure, configuring organizations and domains, and preparing operational documentation. Ongoing support, upgrades and continuous testing are available as separate retainers rather than being assumed inside the initial scope.

How is member onboarding handled when a large customer has thousands of users?

For large customers, the main decisions are how users get into the organization and who approves them. Options include inviting users individually, matching by verified email domain so that users with that domain are linked automatically, or federating the customer's directory or identity provider so the customer's own system remains the source of truth. Each option has different effort: domain matching depends on the domain being verified and kept current, while directory federation needs attribute and group mapping and a plan for users who leave the customer. Ask the customer which system holds the authoritative user list, and confirm how deprovisioning will work, since that is the step most often missed in onboarding designs.

What should we ask for in a written scope before signing for Keycloak Organizations work?

Ask for a written scope that lists each deliverable and the acceptance test for it, not just the work category. Useful items to request include the realm and organization model with the reasons for it, a list of applications and their required claims, the identity providers and domains in scope, the onboarding and offboarding steps with ownership, the environments and upgrade path, and the documentation and handover format. Also ask what is excluded, how changes to scope are priced, what the assumptions are about your infrastructure and access, and who on your side must provide input and within what timeframe. Compare the quote with the cost components described in the implementation plan topic so that recurring items such as hosting, database and support are not hidden.

How DeployOpen scopes, builds and hands over B2B multi-tenancy work

DeployOpen plans and implements Keycloak Organizations inside your own infrastructure, so business customers can be grouped, domain-matched and onboarded within one realm. Each engagement starts from a written scope that defines which organizations, domains and identity providers are covered, and ends with documented configuration your team can operate.

How we scope

  • We agree in writing which organizations, email domains and member onboarding paths the Keycloak Organizations work will cover.
  • We confirm which applications and clients need to recognize organization membership and which tokens or claims they depend on.
  • We record which per-organization identity providers are in scope and which ones your team must supply credentials for.

How we build

  • We configure organizations, domain mappings and member invitations in a non-production realm first, then test sign-in for each organization type.
  • We set up per-organization identity provider links with attribute mapping and first login behavior agreed with your identity team.
  • We test separation between organizations, including members who try to access another organization's applications or resources.

How we hand over

  • We deliver written configuration records covering organizations, domains, identity providers, clients and the admin roles that manage them.
  • We document the onboarding steps your administrators follow when adding a new business customer or changing a domain.
  • We agree with your team when a separate realm is the better choice for a customer, and record that decision and its reasons.

How we support

  • Engagements are fixed-scope, and any change to organizations or identity providers goes through a written scope update.
  • Ongoing support, upgrades and continuous testing are available as retainers, which can cover checks after each Keycloak release.
  • We confirm with your team which support terms and response expectations apply before go-live, since these depend on the agreed contract.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.