I’m trying to configure a little test application which is based on SpringBoot/Vaadin and Kotlin to integrate with Keycloak.
I have an example app which I’ve adapted. This app uses the following settings in the application.yml to configure the Keycloak client and endpoints:
spring:
mustache:
check-template-location: false
application:
name: HelloVaadin
devtools:
restart:
poll-interval: 2s
quiet-period: 1s
security:
oauth2.client.registration.keycloak:
client-id: vaadin-client
authorization-grant-type: authorization_code
scope: openid
client-secret: UrRh3a9CQD25OSmFDvulY7btApvm8b74
oauth2:
client:
provider:
keycloak:
issuer-uri: http://localhost:7979/realms/vaadin-demo
user-name-attribute: preferred_username
token-uri: http://localhost:7979/realms/vaadin-demo/protocol/openid-connect/token
I would like to used a more code based configuration using a ClientRegistrationRepository
with a ClientRegistration
. Unfortunately I have to configure some more properties with the ClientRegistration, like this:
return ClientRegistration.withRegistrationId("vaadin-client")
.clientId("vaadin-client")
.scope("openid")
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST)
.clientSecret("UrRh3a9CQD25OSmFDvulY7btApvm8b74")
.issuerUri("http://localhost:7979/realms/vaadin-demo")
.redirectUri("http://localhost:8080/redirect")
.authorizationUri("http://localhost:7979/realms/vaadin-demo/protocol/openid-connect/auth")
.tokenUri("http://localhost:7979/realms/vaadin-demo/protocol/openid-connect/token")
.userNameAttributeName("preferred_username")
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.build()
When I want to authorise as a user I get redirect to the Keycloak-Login-page where I can provide Username and Password but my GrantedAuthoritiesMapper
– Bean does not get called anymore so I cannot extract the roles which then does not allow me to access pages which check for certain roles.
It all works with the YAML-Based configuration.
I’ve tried certain things but nothing seems to work.
Any help is greatly appreciated.
Best Regards,
Frank