Skip to content

client role mapper to add roles to ID token and userinfo endpoint#15

Merged
apcarp merged 3 commits into
mainfrom
client-roles-mapper
Jun 23, 2026
Merged

client role mapper to add roles to ID token and userinfo endpoint#15
apcarp merged 3 commits into
mainfrom
client-roles-mapper

Conversation

@apcarp

@apcarp apcarp commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Add hooks to enable clients to get user role info in ID tokens and userinfo endpoint. Disables realm-based mapper on default configuration.

@slominskir slominskir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments attached.

Comment thread scripts/kc-lib.sh Outdated
}

update_client_roles_mapper() {
# Update the client-based roles scope so that a user's group IDs are put into the ID token, access token, and userinfo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The access token has roles already by default and code below is only modifying id.token.claim and userinfo.token.claim

Comment thread scripts/defaults/00_config.env Outdated
export KC_SECRET=yHi6W2raPmLvPXoxqMA7VWbLAA2WN0eB
export KC_REALM_DISPLAY_NAME="TEST REALM"
export KC_SERVICE_ACCOUNT_ENABLED=true
export KC_UPDATE_CLIENT_ROLES_MAPPER=true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want this to be the default. We have about a dozen existing clients that don't use this feature and one client that will use it.

Comment thread README.md Outdated
- Each client will use the same client_secret: `yHi6W2raPmLvPXoxqMA7VWbLAA2WN0eB`
- Four users are created all with the password `password`: jadams, jdoe, jsmith, and tbrown
- All users have ${KC_RESOURCE}-user role. jdoe and tbrown have ${KC_RESOURCE}-admin role
- Client has KC_UPDATE_CLIENT_ROLES_MAPPER set to true by default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. A questionable default since none of the existing clients use this.

@apcarp

apcarp commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Agree with comments. Updates made.

@apcarp apcarp merged commit 283d74d into main Jun 23, 2026
1 check passed
@apcarp apcarp deleted the client-roles-mapper branch June 23, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants