Vaadin + Quarkus + Keycloak(OIDC)

I’ve been trying to implement a project that uses Keycloak OIDC. I’ve been following the example from:

but the:
@Inject
SecurityIdentity identity;

in MainView.java is always null.

The code can be found at

in the branch oidc.

The application will direct me to the keycloak login but when I get to the /admin page it says I’m not logged in.

I have struggled with this for the last two days. Please take a look and let me know why this isn’t working.
Thank you
Matthew

Field injection happens after the constructor is called. You need to inject SecurityIdentity as a constructor argument.
The alternative is to move your logic in a @PostConstruct annotated method, but I suggest the constructor injection.

Thank you Marco. This worked well. I’ve also upgraded the project to use NavigationAccessControl.

Still trying to get logout working well. When I press the logout link at the bottom it takes 15 seconds to logout and return to the app.

            anchor = new Anchor("/logout", "Logout");
            anchor.getElement().setAttribute("router-ignore", "");

I hope others find this little app useful.