Indeed, in Keycloak there are many levels of hierarchies (Keycloak instances - realms - organizations - groups - subgroups etc.) The answer depends on your particular requirements, policies, how you plan to implement SSO, protocols you’re planning to use (OIDC/SAML), your application’s cryptographic capabilities and even the expected number of tenants. Depending on that, any combinations could be possible.
[quote=“dteleguin, post:2, topic:30158, full:true”]
Hello @okaydada, We are currently designing a secure identity and access management system with Keycloak to handle multiple user types and applications. Our key requirements are:
Authentication
We want to use OpenID Connect (OIDC) as the main authentication protocol.
Users can authenticate using:
Username + password, or
External Identity Providers (Google, Facebook) via OIDC.
MFA (Multi-Factor Authentication) is mandatory for all users.
We already have users using Google Authenticator (TOTP) for OTP.
We plan to migrate those existing TOTP secrets into Keycloak’s credential storage.
SSO
We want SSO enabled across multiple applications, especially:
Internal apps (for employees),
B2B portals (for enterprise clients),
B2C apps (at least three), where a user account in one app must grant access to the others.
User segmentation
We manage three main user types:
Internal employees
Access an internal app.
Organized by department (HR, support, dev, etc.).
B2B clients
Represented by organizations or top-level groups.
May include multiple users and subgroups per company.
B2C users
End customers using our consumer-facing apps.
Simpler structure, no subgroups needed, but SSO across apps is required.
It looks like the three categories of users (internal, B2B, B2C) are pretty much isolated, and there is no requirement for SSO across the categories. I’d recommend starting with three realms and using groups and/or organizations to model the business hierarchy.
One of the benefits of the above approach is that if any of the realms starts producing significant load (which could affect other user categories), you’ll be able to easily migrate it to a different Keycloak server/cluster.