docs: document opt-in Keycloak role mapping for OAuth2 login - #6083
Merged
Merged
Conversation
Keycloak puts realm and client roles into the access token, so Spring Security maps neither and role checks silently fail. The new VaadinSecurityConfigurer.keycloakRoleMapping() method opts a filter chain in to mapping them, and KeycloakOidcUserMapper does the same for an application that builds its own OidcUserService. Documents vaadin/flow#25627 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…pping The list of granted authorities read as exhaustive but left out the OidcUserAuthority, which the mapper keeps like the default user service, so enabling the mapping looked like it drops OIDC_USER. The JWK set URI can also be configured directly instead of being resolved from the issuer URI, and the abbreviation for a JSON Web Key Set is JWKS. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Preview DeploymentThis PR has been deployed for preview. URL: https://docs-preview-pr-6083.fly.dev Changed pagesAdded content is highlighted in green; removed content is marked in red on each page.
Built from d21e154 |
heruan
reviewed
Sep 21, 2026
Keycloak puts the roles into the access token by default, not always: a client scope mapper can add them to the ID token too. Without the mapping, users are not rejected altogether, only the views and methods that check a role deny access. The role prefix can also come from the servletApi() configuration of the filter chain. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents the new opt-in Keycloak role mapping added in Vaadin 25.4. Keycloak puts user roles into the access token, so Spring Security ignores them and role checks fail silently; the docs now explain how to turn the mapping on.
What changed
Documentation only — no code, no behavior change.
OAuth2 guide (
articles/flow/integrations/spring/oauth2.adoc): new "Keycloak Role Mapping" section that explains why Keycloak roles don't match by default, shows how to enablekeycloakRoleMapping()onVaadinSecurityConfigurer, and lists the authorities the mapping grants (realm roles, client roles for the current client ID,SCOPE_scopes, and theOidcUserAuthority). It also covers the role prefix, the JWKS requirement for decoding the access token, the fallback when no roles can be read, and the sharedOidcUserService. A subsection shows how to useKeycloakOidcUserMapperdirectly when the application builds its ownOidcUserService.Configurer reference (
articles/flow/security/vaadin-security-configurer.adoc): addskeycloakRoleMapping()to the configuration methods, and listsClientRegistrationRepositoryandOidcUserServiceamong the shared beans.Documents vaadin/flow#25627.