Keycloak for Desktop Application with method-level Authenication in Spring Security

Hey all,

I use Keycloak to secure my desktop app with the help of KeycloakInstalled. The app uses spring security to secure the methods with the help of annotations like @PreAuthorize(“hasRole(‘ADMIN’)”). As KeycloakInstalled only returns the token, I was wondering how I could make this combination work? Do you have any hint for me?

I was trying to implement my own UserDetailsService and my own UserPrincipal but figured out that probably the Authentication and SecurityContext will also be important for SpringSecurity to authenticate on a method-level. Sorry if this question is more SpringSecurity related, I just want to make sure that I am not missing something obvious from KeyCloakInstalled

Any idea is greatly appreciated! Thanks!