Class GithubOAuthClientAuthenticationStrategyDelegate
java.lang.Object
com.broadleafcommerce.auth.user.web.authentication.session.AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
com.broadleafcommerce.auth.client.web.authentication.session.AbstractOAuthClientAuthenticationStrategyDelegate
com.broadleafcommerce.auth.client.web.authentication.session.GithubOAuthClientAuthenticationStrategyDelegate
- All Implemented Interfaces:
AuthenticationStrategyDelegate
public class GithubOAuthClientAuthenticationStrategyDelegate
extends AbstractOAuthClientAuthenticationStrategyDelegate
Maps
OAuth2AuthenticationToken
from Github to OAuth2UserDetails
. This
implementation overrides the default behavior of #getEmail, since github users can opt out of
sharing their email address.- Author:
- Cade Rea (cade-rea)
-
Constructor Summary
ConstructorsConstructorDescriptionGithubOAuthClientAuthenticationStrategyDelegate
(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasswordGenerator passwordGenerator) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getEmail
(org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Gets the email attribute from the GitHub authentication.protected String
getName
(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Get the user's name from the authentication token.protected String
Gets the registration type / client registration id that this delegate handlesboolean
boolean
Methods inherited from class com.broadleafcommerce.auth.client.web.authentication.session.AbstractOAuthClientAuthenticationStrategyDelegate
buildUsername, canHandle, getClientId
Methods inherited from class com.broadleafcommerce.auth.user.web.authentication.session.AbstractAuthenticationStrategyDelegate
buildUserRegistration, createAdminUser, generateRandomPassword, getAuthorizedClient, getClientProperties, getClientService, getExternalAdminUserHandler, getOAuth2UserDetails, getOAuth2UserDetailsService, getPasswordGenerator, getRegistrationProperties, getRegistrationService, getTypeFactory, getUsername, getUserType, handleAdminLogin, isAutoRegister, isAutoRegister, isThirdPartyAuth, registerNewUser, registerNewUser, setExternalAdminUserHandler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.auth.user.web.authentication.session.AuthenticationStrategyDelegate
canHandle, getOAuth2UserDetails
-
Constructor Details
-
GithubOAuthClientAuthenticationStrategyDelegate
public GithubOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasswordGenerator passwordGenerator)
-
-
Method Details
-
getOAuthRegistrationType
Description copied from class:AbstractOAuthClientAuthenticationStrategyDelegate
Gets the registration type / client registration id that this delegate handles- Specified by:
getOAuthRegistrationType
in classAbstractOAuthClientAuthenticationStrategyDelegate
- Returns:
- supported registration type
-
getName
protected String getName(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Description copied from class:AbstractAuthenticationStrategyDelegate
Get the user's name from the authentication token.- Overrides:
getName
in classAbstractOAuthClientAuthenticationStrategyDelegate
- Parameters:
authentication
- The User's OAuth token issued by the third-party IDP.- Returns:
- The user's name from the authentication token.
-
getEmail
protected String getEmail(org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Gets the email attribute from the GitHub authentication.- Overrides:
getEmail
in classAbstractOAuthClientAuthenticationStrategyDelegate
- Parameters:
authentication
- the GitHub authentication- Returns:
- the email value if available
- Throws:
MissingOAuth2AuthenticationAttributeException
- if the email value is unavailable
-
emailAttributeMissingError
-
isAdminClientHandler
public boolean isAdminClientHandler()- Returns:
- Does this authentication strategy delegate handle admin users? Default implementation returns true.
-
isCustomerClientHandler
public boolean isCustomerClientHandler()- Returns:
- Does this authentication strategy handle customer users? Default implementation returns true
-