Role Mappers
Map PDC default roles to AW Custom Roles ..
Role Mappers
In this hands-on workshop, you'll learn how to configure Role Mappers in Keycloak to complete the critical bridge between identity management and data governance. We'll walk through configuring User Realm Role and Group Membership mappers that automatically include your Adventure Works custom roles in JWT tokens, enabling PDC to make proper authorization decisions based on complete identity context.
By the end of this workshop, you will be able to:
Configure User Realm Role mappers to include custom roles in JWT tokens
Set up Group Membership mappers for organizational hierarchy visibility
Understand the critical role of mappers in bridging WHO (Keycloak identity) and WHAT (PDC permissions)
Create the complete authentication-to-authorization pipeline for enterprise data governance
Troubleshoot missing role information in JWT tokens
Enable automatic role inheritance through proper mapper configuration
Establish scalable identity federation that supports complex organizational structures
The Critical Integration Challenge This Solves:
Keycloak knows about Adventure Works roles (
aw-sales-analyst
,aw-data-steward
, etc.)PDC needs to know about these roles to make authorization decisions
JWT tokens are the bridge between them, but custom roles aren't included by default
Role Mappers solve this by automatically including realm roles and group memberships in authentication tokens
Workshop Mapper Configuration: You'll create two essential mappers:
AdventureWorks-Realm-Roles
mapper for custom role inclusionAdventureWorks-Groups
mapper for organizational hierarchy context
This workshop completes the WHO + WHAT equation, ensuring that when users authenticate, PDC receives complete identity context to make sophisticated data governance decisions based on both functional permissions and domain-specific access rights.

Keycloak Role Mappers
Keycloak doesn't provide PDC default roles out of the box. The roles like Admin
, Data_Steward
, and Business_User
in your realm are custom roles that were specifically created for your PDC application. Keycloak only provides basic built-in roles like offline_access
and client management roles.
Role mapping is needed because it bridges authentication and authorization. When a user logs in, Keycloak authenticates them and issues a JWT token containing their assigned roles. PDC then reads these roles from the token and needs to understand what permissions to grant. For example, if someone has the aw-sales-analyst
role, PDC needs to know that means "grant access to sales dashboards and customer data."
You need both functional and domain-specific roles working together. PDC functional roles like Business_User
determine what features of the application you can use (dashboards, admin panels, etc.). Your custom AdventureWorks roles like aw-sales-analyst
determine what data domains you can access (sales data, HR data, etc.). The combination gives users complete, appropriate permissions.
The mapping happens in PDC's configuration, not Keycloak. Keycloak's job is just to put the right roles in the JWT token. PDC reads those roles and maps them to specific application permissions. That's why you assign both types of roles to your groups - so users get the complete permission set they need when they authenticate.
Sarah Johnson's Journey:
Sarah logs into PDC
Keycloak checks: "Sarah is in Sales_Analysts group, which has aw-sales-analyst role"
Mapper activates: "I need to include aw-sales-analyst in the token"
JWT created with:
{
"sub": "sarah-uuid",
"preferred_username": "sarah.johnson",
"realm_roles": ["aw-sales-analyst"],
"groups": ["/AdventureWorks_Organization/Sales_Division/Sales_Analysts"]
}
PDC receives token and thinks: "Ah! Sarah has aw-sales-analyst role, so I'll give her Data User permissions and add her to Sales Analytics community"
Keycloak Clients
Clients in Keycloak represent applications or services that need to authenticate users. Each client has a unique Client ID and represents a trust relationship between Keycloak and an application. When a user tries to access an application (like PDC), the application redirects them to Keycloak for authentication, then Keycloak redirects back to the application with an authentication token.
Clients configure how this flow works - what URLs are allowed for redirects, what type of authentication flow to use (like standard web flow or direct grants), and what scopes/claims should be included in the tokens. In your realm, you have clients like pdc-client
(your main PDC application), admin-cli
(for API access), and account
(for user self-service), each configured for their specific authentication needs.
Log into Keycloak:
Username: admin
Password: admin
Ensure you select the Pentaho Data Catalog Realm.
In the Left Menu, Select: Clients
Search and click: pdc-client

Add Client Scope Mappers
Click Client Scopes tab

Click: pdc-client-dedicated

Click Mappers tab

Click Add Mapper → By Configuration.
Click: User Realm Role.

Select the following options:
Name
AdventureWorks-Realm-Roles
Realm Role prefix
Leave blank
Multivalued
✅ ON
Token Claim Name
realm_roles
Claim JSON Type
String
Add to ID Token
✅ ON
Add to Access Token
✅ ON
Add to Userinfo
✅ ON
Click Save.

Repeat the workflow to add: 'Group Membership' mapper:
Select the following options:
Name
AdventureWorks-Groups
Realm Role prefix
Leave blank
Multivalued
✅ ON
Token Claim Name
groups
Full group path
✅ ON
Add to ID Token
✅ ON
Add to Access Token
✅ ON
Add to Userinfo
✅ ON

Click Save.
Last updated
Was this helpful?