keycloak-scim/examples/multi-tenant
2014-12-05 19:03:13 -05:00
..
src/main Multitenancy example working on AS 7.1.1 2014-11-03 10:41:49 +01:00
pom.xml bump version 2014-12-05 19:03:13 -05:00
README.md Fix multi-tenancy on EAP63/AS7 2014-10-31 13:17:35 +01:00
tenant1-realm.json Use relative urls for multi-tenant example 2014-11-04 10:33:49 +01:00
tenant2-realm.json Use relative urls for multi-tenant example 2014-11-04 10:33:49 +01:00

Keycloak Example - Multi Tenancy

The following example was tested on Wildfly 8.1.0.Final and JBoss EAP 6.3. It should be compatible with any JBoss AS, JBoss EAP or Wildfly that supports Java EE 7.

This example demonstrates the simplest possible scenario for Keycloak Multi Tenancy support. Multi Tenancy is understood on this context as a single application (WAR) that is deployed on a single or clustered application server, authenticating users from different realms against a single or clustered Keycloak server.

The multi tenancy is achieved by having one realm per tenant on the server side and a per-request decision on which realm to authenticate the request against.

This example contains only the minimal bits required for a multi tenant application.

This example is composed of the following parts:

  • ProtectedServlet - A servlet that displays the username and realm from the current user
  • PathBasedKeycloakConfigResolver - A configuration resolver that takes the realm based on the path: /simple-multitenant/tenant2 means that the realm is "tenant2".

Step 1: Setup a basic Keycloak server

Install Keycloak server and start it on port 8080. Check the Reference Guide if unsure on how to do it.

Once the Keycloak server is up and running, import the two realms from "src/main/resources/", namely:

  • tenant1-realm.json
  • tenant2-realm.json

Step 2: Deploy and run the example