Configure Keycloak for multi-tenant environment
caution
This guide describes a work-in-progress ACE feature and is intended for testing.
Install and start keycloak
Setup tenant id in Local Keycloak.
Firstly generate an user token in Keycloak referring this documentation - Keycloak User Token
Setup an user attribute with tenant id:
- Open Keycloak in local environment (i.e localhost:8282)
- Click on Administration Console
- Login with credentials
- Select ACE realm
- Navigate to users and select the user you are going to log in with
- Navigate to Attributes and add an Attribute with Key as "tenantId" and Value as "tenant1" or "tenant2".
- Click on save
Create a mapper with the tenant id attribute
- Navigate to Client Scopes -> profile -> Mappers
- Create a Mapper by clicking on Add Mapper -> By Configuration -> User Attribute
- Enter the details for Name, User Attribute , Token Claim Name as "tenantId".