docs: document opt-in Keycloak role mapping for OAuth2 login - #6083
Open
totally-not-ai[bot] wants to merge 2 commits into
Open
totally-not-ai[bot] wants to merge 2 commits into
totally-not-ai[bot] wants to merge 2 commits into
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 e07df36 |
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
Keycloak sends user roles in the access token, which Spring Security does not read, so role checks fail for every user. This adds documentation for the new opt-in role mapping in Vaadin 25.4, which reads those roles and turns them into Spring Security authorities.
What changed
Docs only — no code, no behavior change.
keycloakRoleMapping(), and what authorities the mapping grants (realm roles, client roles for the current client ID,SCOPE_authorities, and theOidcUserAuthority).ROLE_by default, or whatever aGrantedAuthorityDefaultsbean sets).oauth2LoginPage(), and it needs the provider's JWKS (fromissuer-urior an explicitjwk-set-uri). If the token can't be decoded, login still works but the user gets no roles.OidcUserService: use theKeycloakOidcUserMapperconverter instead ofkeycloakRoleMapping(), with an optional custom role prefix.VaadinSecurityConfigurerreference page: documents thekeycloakRoleMapping()method and addsClientRegistrationRepositoryandOidcUserServiceto the list of shared beans.Documents vaadin/flow#25627