Keycloak basic authentication with Spring Security 6

Try to migrate to using standard OpenID Connect with Spring Security for authentication purposes and OAuth 2.0 acting as Resource Server related to APIs for authorization.

Here, you have an example with multiples OIDC providers:

Alternatively, you can check out an API (RS) example: