public final class OAuth2AuthorizationCodeRequestAuthenticationProvider
extends java.lang.Object
implements org.springframework.security.authentication.AuthenticationProvider
AuthenticationProvider implementation for the OAuth 2.0 Authorization Request (and Consent)
used in the Authorization Code Grant.| Constructor and Description |
|---|
OAuth2AuthorizationCodeRequestAuthenticationProvider(RegisteredClientRepository registeredClientRepository,
OAuth2AuthorizationService authorizationService,
OAuth2AuthorizationConsentService authorizationConsentService)
Constructs an
OAuth2AuthorizationCodeRequestAuthenticationProvider using the provided parameters. |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.security.core.Authentication |
authenticate(org.springframework.security.core.Authentication authentication) |
void |
setAuthenticationValidatorResolver(java.util.function.Function<java.lang.String,OAuth2AuthenticationValidator> authenticationValidatorResolver)
Sets the resolver that resolves an
OAuth2AuthenticationValidator from the provided OAuth 2.0 Authorization Request parameter. |
void |
setAuthorizationCodeGenerator(OAuth2TokenGenerator<OAuth2AuthorizationCode> authorizationCodeGenerator)
Sets the
OAuth2TokenGenerator that generates the OAuth2AuthorizationCode. |
void |
setAuthorizationConsentCustomizer(java.util.function.Consumer<OAuth2AuthorizationConsentAuthenticationContext> authorizationConsentCustomizer)
Sets the
Consumer providing access to the OAuth2AuthorizationConsentAuthenticationContext
containing an OAuth2AuthorizationConsent.Builder and additional context information. |
boolean |
supports(java.lang.Class<?> authentication) |
public OAuth2AuthorizationCodeRequestAuthenticationProvider(RegisteredClientRepository registeredClientRepository, OAuth2AuthorizationService authorizationService, OAuth2AuthorizationConsentService authorizationConsentService)
OAuth2AuthorizationCodeRequestAuthenticationProvider using the provided parameters.registeredClientRepository - the repository of registered clientsauthorizationService - the authorization serviceauthorizationConsentService - the authorization consent servicepublic org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication)
throws org.springframework.security.core.AuthenticationException
authenticate in interface org.springframework.security.authentication.AuthenticationProviderorg.springframework.security.core.AuthenticationExceptionpublic boolean supports(java.lang.Class<?> authentication)
supports in interface org.springframework.security.authentication.AuthenticationProviderpublic void setAuthorizationCodeGenerator(OAuth2TokenGenerator<OAuth2AuthorizationCode> authorizationCodeGenerator)
OAuth2TokenGenerator that generates the OAuth2AuthorizationCode.authorizationCodeGenerator - the OAuth2TokenGenerator that generates the OAuth2AuthorizationCodepublic void setAuthenticationValidatorResolver(java.util.function.Function<java.lang.String,OAuth2AuthenticationValidator> authenticationValidatorResolver)
OAuth2AuthenticationValidator from the provided OAuth 2.0 Authorization Request parameter.
The following OAuth 2.0 Authorization Request parameters are supported:
OAuth2ParameterNames.REDIRECT_URIOAuth2ParameterNames.SCOPE
NOTE: The resolved OAuth2AuthenticationValidator MUST throw OAuth2AuthorizationCodeRequestAuthenticationException if validation fails.
authenticationValidatorResolver - the resolver that resolves an OAuth2AuthenticationValidator from the provided OAuth 2.0 Authorization Request parameterpublic void setAuthorizationConsentCustomizer(java.util.function.Consumer<OAuth2AuthorizationConsentAuthenticationContext> authorizationConsentCustomizer)
Consumer providing access to the OAuth2AuthorizationConsentAuthenticationContext
containing an OAuth2AuthorizationConsent.Builder and additional context information.
The following context attributes are available:
OAuth2AuthorizationConsent.Builder used to build the authorization consent
prior to OAuth2AuthorizationConsentService.save(OAuth2AuthorizationConsent).Authentication of type
OAuth2AuthorizationCodeRequestAuthenticationToken.RegisteredClient associated with the authorization request.OAuth2Authorization associated with the state token presented in the
authorization consent request.OAuth2AuthorizationRequest associated with the authorization consent request.authorizationConsentCustomizer - the Consumer providing access to the
OAuth2AuthorizationConsentAuthenticationContext containing an OAuth2AuthorizationConsent.Builder