KeyCloak integration with Vaadin

Hi,
I’m looking for samples on integrating Vaadin with KeyCloak similiar to what https://github.com/mauriciovigolo/keycloak-angular provides for Angular (that is: redirecting to KEyCloak Login, retrieving token, automatically using the token in each request afterwards).

Do you know of something about it out there?

best
Markus

Hi Markus. I haven’t seen any integration, yet. But out of interest, would you be looking to use KeyCloak to auth the user (browser) for the Vaadin app (server) or for authenticating the Vaadin app to talk with external REST services ? Just trying to wrap my head around what you want to achieve and thus what would be needed.

Hi Markus, have a look at https://github.com/Informaten/Wildcloak.
It’s an example for running a Vaadin 10 app on a Wilfly Server.
I’ve tried it and it works fine!

Currently I’m also trying to adapt this example to my Vaadin 8 App. But there’re differences in URI- and navigation handling between Vaadin 8 and Vaadin >= 10 and these differences causes problems (Keycloak does not accept redirect-uri containing “#!”, followed by the viewname.)

Good luck
Norbert

Hi
@Pekka: I’m looking for the first scenario: Want do redirect to Keycloak for login and have the principal with roles, etc then available within Vaadin.

@Norbert, thanks a lot, I’ll check it out :slight_smile:

best
Markus

Hi @Markus! Please check out this tutorial series https://ramonak.io/posts/springboot–vaadin-keycloak–springsecurity-integration. There is a part about KeycloakRestTemplate, which helps to use access token in each request

Hi @Katsiaryna! THanks a lt for pointing me there - the link is not working but I found the articles and the sample on github, great things!
YOur demo is working well, but as I tried to adopt it to a project with vaadin 15 just generated from https://vaadin.com/start/latest, I run into CORS problems when redirecting to my keycloak instance or into XHR request on the vaadin app itself.
I’m currently sorting out things a will try to come back with a sample - in case someone has struggled with something like these, I happy for hints :wink:

Markus Schlichting:
Hi @Katsiaryna! THanks a lt for pointing me there - the link is not working but I found the articles and the sample on github, great things!
YOur demo is working well, but as I tried to adopt it to a project with vaadin 15 just generated from https://vaadin.com/start/latest, I run into CORS problems when redirecting to my keycloak instance or into XHR request on the vaadin app itself.
I’m currently sorting out things a will try to come back with a sample - in case someone has struggled with something like these, I happy for hints :wink:

I’ve updated the link (I was refactoring my site and forgot to update the link here, sorry).
Unfortunately, I haven’t checked Vaadin 15 yet. So, I can’t tell why there is a problem with CORS.
Anyway, it would be great if you could solve this problem and give the link to the sample code.