Class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<OAuth2ClientConfigurer<B>, B>
org.springframework.security.config.annotation.web.configurers.oauth2.client.OAuth2ClientConfigurer<B>
- All Implemented Interfaces:
SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, B>
public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>>
extends AbstractHttpConfigurer<OAuth2ClientConfigurer<B>, B>
An
AbstractHttpConfigurer for OAuth 2.0 Client support.
The following configuration options are available:
authorizationCodeGrant(Customizer)- support for the OAuth 2.0 Authorization Code Grant
Defaults are provided for all configuration options with the only required
configuration being
clientRegistrationRepository(ClientRegistrationRepository). Alternatively, a
ClientRegistrationRepository @Bean may be registered instead.
Security Filters
The followingFilter's are populated for
authorizationCodeGrant(Customizer):
OAuth2AuthorizationRequestRedirectFilterOAuth2AuthorizationCodeGrantFilter
Shared Objects Created
The following shared objects are populated:ClientRegistrationRepository(required)OAuth2AuthorizedClientRepository(optional)
Shared Objects Used
The following shared objects are used:ClientRegistrationRepositoryOAuth2AuthorizedClientRepository
- Since:
- 5.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classConfiguration options for the OAuth 2.0 Authorization Code Grant. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthorizationCodeGrant(Customizer<OAuth2ClientConfigurer<B>.AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer) Configures the OAuth 2.0 Authorization Code Grant.authorizedClientRepository(org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository authorizedClientRepository) Sets the repository for authorized client(s).authorizedClientService(org.springframework.security.oauth2.client.OAuth2AuthorizedClientService authorizedClientService) Sets the service for authorized client(s).clientRegistrationRepository(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository) Sets the repository of client registrations.voidConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.voidInitialize theSecurityBuilder.Methods inherited from class AbstractHttpConfigurer
disable, getRequestMatcherBuilder, getSecurityContextHolderStrategy, withObjectPostProcessorMethods inherited from class SecurityConfigurerAdapter
addObjectPostProcessor, getBuilder, postProcess, setBuilder
-
Constructor Details
-
OAuth2ClientConfigurer
public OAuth2ClientConfigurer()
-
-
Method Details
-
clientRegistrationRepository
public OAuth2ClientConfigurer<B> clientRegistrationRepository(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository clientRegistrationRepository) Sets the repository of client registrations.- Parameters:
clientRegistrationRepository- the repository of client registrations- Returns:
- the
OAuth2ClientConfigurerfor further configuration
-
authorizedClientRepository
public OAuth2ClientConfigurer<B> authorizedClientRepository(org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository authorizedClientRepository) Sets the repository for authorized client(s).- Parameters:
authorizedClientRepository- the authorized client repository- Returns:
- the
OAuth2ClientConfigurerfor further configuration
-
authorizedClientService
public OAuth2ClientConfigurer<B> authorizedClientService(org.springframework.security.oauth2.client.OAuth2AuthorizedClientService authorizedClientService) Sets the service for authorized client(s).- Parameters:
authorizedClientService- the authorized client service- Returns:
- the
OAuth2ClientConfigurerfor further configuration
-
authorizationCodeGrant
public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<OAuth2ClientConfigurer<B>.AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer) Configures the OAuth 2.0 Authorization Code Grant.- Parameters:
authorizationCodeGrantCustomizer- theCustomizerto provide more options for theOAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>>.AuthorizationCodeGrantConfigurer- Returns:
- the
OAuth2ClientConfigurerfor further customizations
-
init
Description copied from interface:SecurityConfigurerInitialize theSecurityBuilder. Here only shared state should be created and modified, but not properties on theSecurityBuilderused for building the object. This ensures that theSecurityConfigurer.configure(SecurityBuilder)method uses the correct shared objects when building. Configurers should be applied here.- Specified by:
initin interfaceSecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, B extends HttpSecurityBuilder<B>>- Overrides:
initin classSecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, B extends HttpSecurityBuilder<B>>- Parameters:
builder-
-
configure
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, B extends HttpSecurityBuilder<B>>- Overrides:
configurein classSecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, B extends HttpSecurityBuilder<B>>- Parameters:
builder-
-