Class AnonymousConfigurer<H extends HttpSecurityBuilder<H>>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<AnonymousConfigurer<H>,H>
org.springframework.security.config.annotation.web.configurers.AnonymousConfigurer<H>
- All Implemented Interfaces:
SecurityConfigurer<DefaultSecurityFilterChain,H>
public final class AnonymousConfigurer<H extends HttpSecurityBuilder<H>>
extends AbstractHttpConfigurer<AnonymousConfigurer<H>,H>
Configures Anonymous authentication (i.e. populate an
Authentication that
represents an anonymous user instead of having a null value) for an
HttpSecurity. Specifically this will configure an
AnonymousAuthenticationFilter and an AnonymousAuthenticationProvider.
All properties have reasonable defaults, so no additional configuration is required
other than applying this SecurityConfigurer.- Since:
- 3.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticationFilter(AnonymousAuthenticationFilter authenticationFilter) Sets theAnonymousAuthenticationFilterused to populate an anonymous user.authenticationProvider(AuthenticationProvider authenticationProvider) Sets theAuthenticationProviderused to validate an anonymous user.authorities(String... authorities) Sets theAuthentication.getAuthorities()for anonymous usersauthorities(List<GrantedAuthority> authorities) Sets theAuthentication.getAuthorities()for anonymous usersvoidConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.voidInitialize theSecurityBuilder.Sets the key to identify tokens created for anonymous authentication.Sets the principal forAuthenticationobjects of anonymous usersMethods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, getSecurityContextHolderStrategy, withObjectPostProcessor, withObjectPostProcessorMethods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
-
Constructor Details
-
AnonymousConfigurer
public AnonymousConfigurer()Creates a new instance- See Also:
-
-
Method Details
-
key
Sets the key to identify tokens created for anonymous authentication. Default is a secure randomly generated key.- Parameters:
key- the key to identify tokens created for anonymous authentication. Default is a secure randomly generated key.- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
principal
Sets the principal forAuthenticationobjects of anonymous users- Parameters:
principal- used for theAuthenticationobject of anonymous users- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
authorities
Sets theAuthentication.getAuthorities()for anonymous users- Parameters:
authorities- Sets theAuthentication.getAuthorities()for anonymous users- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
authorities
Sets theAuthentication.getAuthorities()for anonymous users- Parameters:
authorities- Sets theAuthentication.getAuthorities()for anonymous users (i.e. "ROLE_ANONYMOUS")- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
authenticationProvider
Sets theAuthenticationProviderused to validate an anonymous user. If this is set, no attributes on theAnonymousConfigurerwill be set on theAuthenticationProvider.- Parameters:
authenticationProvider- theAuthenticationProviderused to validate an anonymous user. Default isAnonymousAuthenticationProvider- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
authenticationFilter
public AnonymousConfigurer<H> authenticationFilter(AnonymousAuthenticationFilter authenticationFilter) Sets theAnonymousAuthenticationFilterused to populate an anonymous user. If this is set, no attributes on theAnonymousConfigurerwill be set on theAnonymousAuthenticationFilter.- Parameters:
authenticationFilter- theAnonymousAuthenticationFilterused to populate an anonymous user.- Returns:
- the
AnonymousConfigurerfor further customization of anonymous authentication
-
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<DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>> - Overrides:
initin classSecurityConfigurerAdapter<DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>
-
configure
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>> - Overrides:
configurein classSecurityConfigurerAdapter<DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>>
-