Class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>>
- java.lang.Object
-
- org.springframework.security.config.annotation.SecurityConfigurerAdapter<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<DefaultSecurityFilterChain,B>
public final class OAuth2ClientConfigurer<B extends HttpSecurityBuilder<B>> extends AbstractHttpConfigurer<OAuth2ClientConfigurer<B>,B>
AnAbstractHttpConfigurerfor OAuth 2.0 Client support.The following configuration options are available:
authorizationCodeGrant()- 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, aClientRegistrationRepository@Beanmay be registered instead.Security Filters
The followingFilter's are populated forauthorizationCodeGrant():Shared Objects Created
The following shared objects are populated:ClientRegistrationRepository(required)OAuth2AuthorizedClientRepository(optional)
Shared Objects Used
The following shared objects are used:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classOAuth2ClientConfigurer.AuthorizationCodeGrantConfigurerConfiguration options for the OAuth 2.0 Authorization Code Grant.
-
Constructor Summary
Constructors Constructor Description OAuth2ClientConfigurer()
-
Method Summary
-
Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, withObjectPostProcessor
-
Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
-
-
-
-
Method Detail
-
clientRegistrationRepository
public OAuth2ClientConfigurer<B> clientRegistrationRepository(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(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(OAuth2AuthorizedClientService authorizedClientService)
Sets the service for authorized client(s).- Parameters:
authorizedClientService- the authorized client service- Returns:
- the
OAuth2ClientConfigurerfor further configuration
-
authorizationCodeGrant
public OAuth2ClientConfigurer.AuthorizationCodeGrantConfigurer authorizationCodeGrant()
Returns theOAuth2ClientConfigurer.AuthorizationCodeGrantConfigurerfor configuring the OAuth 2.0 Authorization Code Grant.
-
authorizationCodeGrant
public OAuth2ClientConfigurer<B> authorizationCodeGrant(Customizer<OAuth2ClientConfigurer.AuthorizationCodeGrantConfigurer> authorizationCodeGrantCustomizer)
Configures the OAuth 2.0 Authorization Code Grant.- Parameters:
authorizationCodeGrantCustomizer- theCustomizerto provide more options for theOAuth2ClientConfigurer.AuthorizationCodeGrantConfigurer- Returns:
- the
OAuth2ClientConfigurerfor further customizations
-
init
public void init(B builder)
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<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>- Overrides:
initin classSecurityConfigurerAdapter<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
-
configure
public void configure(B builder)
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>- Overrides:
configurein classSecurityConfigurerAdapter<DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>>
-
-