KeycloakAuthenticationToken vs OAuth2Authentication

Hi

I method security with spring boot (@PreAuthorize annotation)

I configure OAuth2MethodSecurityExpressionHandler

The problem is The authenticaiton object that is created is KeycloakAuthenticationToken but OAuth2MethodSecurityExpressionHandler requires OAuth2Authentication object.

I am having to use DefaultMethodSecurityExpressionHandler for KeycloakTokenAuthentication.

But DefaultMethodSecurityExpressionHandler does not have methods such as isClient() or isUser()

how Can i convert KeycloakAuthenticationToken to OAuth2Authentication??

id be pleased if you could help

Thanks

Servet