Class FederatedOAuth2UserService

java.lang.Object
com.irurueta.authserver.authorization.api.web.social.FederatedOAuth2UserService
All Implemented Interfaces:
org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,org.springframework.security.oauth2.core.user.OAuth2User>

public class FederatedOAuth2UserService extends Object implements org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,org.springframework.security.oauth2.core.user.OAuth2User>
The user service of the providers that are plain OAuth 2.0 (GitHub), which have no ID token: the framework's service reads the profile from the provider's API, the verified primary e-mail address is read from /user/emails (through the domain port VerifiedEmailLookup, implemented by the GitHub adapter of infrastructure/github with a client generated from the contract of that GitHub operation), the account is resolved (found, linked by verified e-mail or provisioned, and refused when it may not sign in) and the principal becomes the local one, named after the account. The stable subject is GitHub's numeric id, never the login name or the e-mail address, which the user can change.
  • Field Details

    • KEPT_ATTRIBUTES

      static final List<String> KEPT_ATTRIBUTES
      Attributes of GitHub's profile that are kept in the session: scalars only.
    • MISSING_USER

      private static final String MISSING_USER
      Message of the failure when the framework's service answers no user.
      See Also:
    • delegate

      private final org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,org.springframework.security.oauth2.core.user.OAuth2User> delegate
      The framework's service, which reads the profile.
    • verifiedEmailLookup

      private final VerifiedEmailLookup verifiedEmailLookup
      Reads the verified primary e-mail address.
    • accountResolver

      private final FederatedAccountResolver accountResolver
      Resolves the local account.
    • userMapper

      private final FederatedUserMapper userMapper
      Builds the local principal.
  • Constructor Details

    • FederatedOAuth2UserService

      public FederatedOAuth2UserService()
  • Method Details

    • loadUser

      public org.springframework.security.oauth2.core.user.OAuth2User loadUser(org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest request) throws org.springframework.security.oauth2.core.OAuth2AuthenticationException
      Loads the user of a sign-in.
      Specified by:
      loadUser in interface org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest,org.springframework.security.oauth2.core.user.OAuth2User>
      Parameters:
      request - the request, with the registration and the access token.
      Returns:
      the local principal.
      Throws:
      org.springframework.security.oauth2.core.OAuth2AuthenticationException - if the provider is not GitHub or the sign-in is refused.