Class KeycloakOauth2UserService

java.lang.Object
org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService
digital.nedra.commons.starter.keycloak.session.config.support.KeycloakOauth2UserService
All Implemented Interfaces:
org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest,org.springframework.security.oauth2.core.oidc.user.OidcUser>

@Component public class KeycloakOauth2UserService extends org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.oauth2.core.oidc.user.OidcUser
    loadUser(org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest userRequest)
    Augments OidcUserService.loadUser(OidcUserRequest) to add authorities provided by Keycloak.

    Methods inherited from class org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService

    createDefaultClaimTypeConverters, setAccessibleScopes, setClaimTypeConverterFactory, setOauth2UserService

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • KeycloakOauth2UserService

      public KeycloakOauth2UserService()
  • Method Details

    • loadUser

      public org.springframework.security.oauth2.core.oidc.user.OidcUser loadUser(org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest userRequest) throws org.springframework.security.oauth2.core.OAuth2AuthenticationException
      Augments OidcUserService.loadUser(OidcUserRequest) to add authorities provided by Keycloak. Needed because OidcUserService.loadUser(OidcUserRequest) (currently) does not provide a hook for adding custom authorities from aOidcUserRequest.
      Specified by:
      loadUser in interface org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest,org.springframework.security.oauth2.core.oidc.user.OidcUser>
      Overrides:
      loadUser in class org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService
      Throws:
      org.springframework.security.oauth2.core.OAuth2AuthenticationException