Skip to content
B2B SaaS

Keycloak for B2B SaaS enterprise SSO

Your customers want their staff to reach your product through the login their company already uses. Keycloak brokers each company’s identity provider over SAML or OpenID Connect, so your app trusts one issuer and reads the customer from the token.

Point here to play
A simplified drawing. The customer names are placeholders.
The short answer

Put your product’s users in one realm, turn on Organizations, and give each customer company an organization. Link that company’s identity provider, SAML 2.0 or OpenID Connect, to its organization and route its email domain to it. People type their work email, Keycloak sends them to their own company login, and your app gets one kind of token with an organization claim. Give a customer a realm of its own only when it needs settings no other customer can share.

How it works

Built from Keycloak’s own parts

Realms, clients, authentication flows and mappers, as the standard admin console has them. Nothing here needs a custom extension.

One realm, one organization per customer

A realm holds your users, your clients and the flows that sign people in. Organizations, fully supported since Keycloak 26.0, divide one realm by customer company. You turn the feature on per realm under Realm settings, then manage each customer under Organizations in the menu.

Each organization holds what one customer needs:

  • Its members, added by invitation, by hand, or automatically the first time they sign in through the company’s identity provider.
  • Its email domains, such as customer-a.com. A domain belongs to one organization in the realm.
  • Its linked identity providers. Since Keycloak 26.8 one provider can be linked to several organizations, each with its own membership settings.
  • Its own groups, so each customer’s teams do not collide with another’s.

Your app keeps one client, one issuer and one set of keys. Adding a customer is configuration in the realm, not a new deployment.

Brokering each customer’s identity provider

For each customer, add an identity provider in the realm. For SAML v2.0, import the customer’s metadata by URL or file; for OpenID Connect v1.0, enter their discovery URL, client ID and secret. Then link the provider to the customer’s organization.

The customer needs your side of the connection. For SAML, hand them the service provider metadata Keycloak publishes for that provider:

Service provider metadata for the provider with alias customer-a
https://auth.yourcompany.com/realms/your-product/broker/customer-a/endpoint/descriptor

For OpenID Connect, they register https://auth.yourcompany.com/realms/your-product/broker/customer-b/endpoint as the redirect URI in their identity provider.

Then route the domain. On the organization’s Domains tab, pick the identity provider for each domain and turn on Auto redirect. The login page asks for the email first; a user at customer-a.com goes straight to Customer A’s login. A user who already has a password or a passkey in the realm is asked for it instead of being redirected.

Mappers and first login

Identity provider mappers turn what the customer’s provider sends into your user’s attributes and roles: an attribute importer for names and email, a hardcoded role for everyone from that company, or a mapping from a SAML attribute or OIDC claim to a role. The first broker login flow decides what happens the first time someone arrives: create the account, or link it to an existing one after they prove they own it.

What reaches your app

When your client asks for the organization scope, the tokens name the user’s organization:

Part of an access token. The ID and attributes are added when you turn them on in the mapper
"organization": {
  "customer-a": {}
}

Your API checks that claim before it returns a customer’s data. A user who belongs to several organizations picks one at sign-in when the client asks for plain organization, or gets all of them with organization:*. Roles work as usual, and since Keycloak 26.7 a role given to an organization group reaches every member’s token.

Organizations or a realm per customer

Organizations in one realmA realm per customer
Clients and issuerOne of each for all customersOne per customer, so your app trusts many issuers
Login settingsShared: password policy, sessions, flowsSeparate for each customer
Adding a customerA new organization and identity providerA new realm with its own clients
A person in two customersOne account, member of bothTwo separate accounts
Realms on our plansOne realm covers every customer2, 20 or 100 realms, by plan

Most products start with Organizations. The trade-offs are on Multi-tenant apps.

Who does what

We run the server. You shape the realm.

RealmDeploy runs
  • Upstream Keycloak 26, where Organizations is a supported feature, upgraded by us
  • Outbound network rules from your Keycloak to each identity provider it must reach, opened per host when you ask, because outbound traffic is closed by default
  • HTTPS on your own domain, so the URLs you hand to customers stay the same
  • Nightly backups with point-in-time restore of every realm, organization and link
  • Monitoring, alerts and our on-call
You configure, in the admin console
  • Organizations turned on in the realm, one per customer, with its domains
  • Each customer’s identity provider, its certificates and its mappers
  • Domain routing and auto redirect
  • Your app’s client and the organization scope
  • The first broker login flow and account linking rules
Which plan

Usually Premium

The plans are sized by realms and by active users a month: people who sign in at least once in the month. These are sizing guides, not hard caps.

Starter$199 a month
  • Dedicated Keycloak, 1 replica
  • Up to 2 realms
  • Sized for about 5,000 active users a month
  • Best effort, no uptime SLA
Fits this jobPremium$999 a month
  • High-availability cluster, 2+ replicas
  • Up to 20 realms
  • Sized for about 100,000 active users a month
  • 99.9% monthly uptime SLA
Enterprise$2,499 a month
  • Larger high-availability cluster
  • Up to 100 realms
  • Sized for about 500,000 active users a month
  • 99.95% monthly uptime SLA

Enterprise SSO is something your customers rely on, so a login outage is their outage. Premium runs two or more Keycloak replicas with a 99.9% monthly SLA and is sized for about 100,000 active users a month. Organizations live in one realm, so the realm count rarely limits you. Starter suits a pilot with a few customers: about 5,000 active users, one replica and no SLA. Enterprise fits past about 100,000 active users, or when your customers ask for a 99.95% SLA and help with their security review.

Every plan, feature by feature

Questions

Frequently asked questions

Should every customer get its own realm?

Usually not. One realm with Organizations keeps one client and one issuer for your app, and each customer is an organization with its own identity provider. Give a customer its own realm only when it needs its own password policy, session lengths or login flow.

Which identity providers can my customers bring?

Any that speaks SAML 2.0 or OpenID Connect, which covers Microsoft Entra ID, Okta, Google Workspace, ADFS and most others. Keycloak brokers them as standard identity providers; nothing custom is needed.

Can one person belong to two customers?

Yes. With Organizations a user has one account in the realm and can be a member of several organizations. Your client asks for the organization scope; if the user belongs to more than one, Keycloak asks which one at sign-in, or returns all of them when the client asks for organization:*.

Can my customers set up their own SSO connection?

Keycloak has no setup wizard for your customers. Your team adds each connection in the admin console, or your own onboarding screen calls Keycloak’s admin REST API on your domain. Since Keycloak 26.7, the manage-organizations role lets you delegate organization management without giving full realm admin.

Do you provision users with SCIM?

SCIM provisioning is not part of RealmDeploy today. Users are created the first time they sign in through their company’s identity provider, and you disable or remove them in the admin console or through the admin REST API.

What happens when a customer’s identity provider is down?

People from that customer cannot start new sessions until it is back, because their company login is the one that checks them. Sessions already open in Keycloak keep working until they expire. Other customers are not affected.

Why do you need to know which identity providers we use?

For OpenID Connect, Keycloak calls the provider’s token and keys endpoints from the server, and fetching SAML metadata by URL is a server call too. Outbound traffic from your Keycloak is closed by default, so we open it to the hosts you name.

Run it on a cluster of your own

Order a realm in the dashboard, or write to us first about what you are building.