Just wanted to share a guide on how to link a Vaadin Flow v24 to Keycloak as an OAuth2 client for both Authentication (login handled by Keycloak) and Authorization (protect views with roles).
It worked for me with Vaadin 24 & Spring Boot 3, but not with Vaadin 25 & Spring Boot 4. Any idea why that might be? I get redirected to the keycloak login page and can login, but then i get into a redirect loop without being able to access the application.
Which URL gets the redirect?
In Vaadin 24 there was an authenticated() rule for anyRequest() matcher. This default has been removed in Vaadin 25, so URL that do not match any registered matcher are forbidden. Could this be your case?
Any idea what i could be missing? The initial redirection to keycloak works, the redirection loop happens after authentication and accessing views while the browser has a valid token.
2026-01-08T13:12:51.180+01:00 DEBUG 34156 — [io-4200-exec-10] o.s.s.authentication.ProviderManager : Authentication failed with provider OidcAuthorizationCodeAuthenticationProvider since [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for “https://…/auth/realms/…/protocol/openid-connect/token”: EOF reached while reading
What i found is that DefaultAuthorizationCodeTokenResponseClient was removed in Spring Boot 4, which was used in Vaadin 24, now AbstractRestClientOAuth2AccessTokenResponseClient is used and causes the error above.
It seems like something is not properly configured, but it is hard to say what from the above information. Double-check that the Keycloak URL is correct and that it responds correctly.
Hello,
I have migrated my own project from Vaadin Flow 24 to Vaadin Flow 25 and I didn’t face any Keycloak/Spring Security issue. The only thing I noticed you have is the resource server dependency/config, not sure if it is causing some issue or it’s really needed.
For me, I have: