Step 2 - Manage Organizations
Go to Organizations, click on Create Organization
and set :
- Name
- Alias (unique URL-friendly identifier)
- Domains (match users via email)
- Redirect URL and optional attributes
- Description
- Customize onboarding, domain restrictions, IDPs, invitations per organization.
- You can disable or delete organizations to prevent login within their context.
Step 3 - Assign Roles to Users or Groups
Assign to Users
- Go to Users, on the left side
- Select the users
- open the tab "Role Mappings"
- Click Assign Role,
- select realm or client roles, and click Assign.
Assign to Groups
- Move to the groupe section on the left side
- select the appropriate group.
- Under Role Mappings, assign roles. Members inherit them.
Restrict Roles in Tokens
- Go to clients
- Select the application you need
- Go to Client scope tab and select the line of your client,
- Go to the tab "Scope" and make sure Full scope allowed is enabled
Step 4 - Include Organization Info in OIDC Token
- Create a Client Scope (e.g.
organization:*). - Add a mapper of type Organization Membership.
- Configure it to include organization
alias and/or ID. - Set the scope as Default or assign as Optional for your client.
{
"organization": [
{"alias": "org1", "name": "Org One"}
],
"organizationId": "a56bea03-5904-470a-b21c-92b7f1069d44"
}
Step 5 - Include Roles and Groups in Tokens
"realm_access": {
"roles": ["admin", "user"]
},
"resource_access": {
"my-client-id": {
"roles": ["app-role"]
}
},
"groups": ["/group1/subgroup", "admins"]
Summary Table
| Steps | Description |
|---|
| Enable Organizations | Realm Settings → General → Toggle ON |
| Manage Orgs | Create orgs with alias, domain, redirect |
| Assign Roles | Via user or group Role Mappings |
| Org Claim in Token | Create organization:* scope and mapper |
| Limit Roles in Token | Set Full Scope Allowed = OFF; define explicitly |
| Include Groups | Group Membership mapper |
Step 6 - Sample OIDC Authentication Flow
- User initiates login to your app
- OIDC request includes:
scope=openid profile organization:* Token includes:
organization & organizationId claimsrealm_access, resource_access rolesgroups (if mapped)
- Your app enforces authorization using these claims
- Important endpoints, you need to take care :
- Use organization:* scope to fetch all orgs if user has more than one.
- Composite roles automatically include their children roles in tokens.
- Disable Full Scope and map scopes explicitly to limit exposure.
If you need JSON config samples, client scope exports, or tailored examples for your stack (Node.js, Spring, etc.), just ask!