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 Summary
FieldsModifier and TypeFieldDescriptionprivate final FederatedAccountResolverResolves the local account.private final org.springframework.security.oauth2.client.userinfo.OAuth2UserService<org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest, org.springframework.security.oauth2.core.user.OAuth2User> The framework's service, which reads the profile.Attributes of GitHub's profile that are kept in the session: scalars only.private static final StringMessage of the failure when the framework's service answers no user.private final FederatedUserMapperBuilds the local principal.private final VerifiedEmailLookupReads the verified primary e-mail address. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.oauth2.core.user.OAuth2UserloadUser(org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest request) Loads the user of a sign-in.
-
Field Details
-
KEPT_ATTRIBUTES
Attributes of GitHub's profile that are kept in the session: scalars only. -
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> delegateThe framework's service, which reads the profile. -
verifiedEmailLookup
Reads the verified primary e-mail address. -
accountResolver
Resolves the local account. -
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:
loadUserin interfaceorg.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.
-