Class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<HttpBasicConfigurer<B>,B>
org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer<B>
- All Implemented Interfaces:
SecurityConfigurer<DefaultSecurityFilterChain,
B>
public final class HttpBasicConfigurer<B extends HttpSecurityBuilder<B>>
extends AbstractHttpConfigurer<HttpBasicConfigurer<B>,B>
Adds HTTP basic based authentication. All attributes have reasonable defaults making
all parameters are optional.
Security Filters
The following Filters are populatedShared Objects Created
- AuthenticationEntryPoint - populated with the
authenticationEntryPoint(AuthenticationEntryPoint)
(defaultBasicAuthenticationEntryPoint
)
Shared Objects Used
The following shared objects are used:- Since:
- 3.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionauthenticationDetailsSource
(AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest, ?> authenticationDetailsSource) Specifies a customAuthenticationDetailsSource
to use for basic authentication.authenticationEntryPoint
(AuthenticationEntryPoint authenticationEntryPoint) TheAuthenticationEntryPoint
to be populated onBasicAuthenticationFilter
in the event that authentication fails.void
Configure theSecurityBuilder
by setting the necessary properties on theSecurityBuilder
.void
Initialize theSecurityBuilder
.Allows easily changing the realm, but leaving the remaining defaults in place.securityContextRepository
(SecurityContextRepository securityContextRepository) Specifies a customSecurityContextRepository
to use for basic authentication.Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, getSecurityContextHolderStrategy, withObjectPostProcessor, withObjectPostProcessor
Methods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
-
Constructor Details
-
HttpBasicConfigurer
public HttpBasicConfigurer()Creates a new instance- See Also:
-
-
Method Details
-
realmName
Allows easily changing the realm, but leaving the remaining defaults in place. IfauthenticationEntryPoint(AuthenticationEntryPoint)
has been invoked, invoking this method will result in an error.- Parameters:
realmName
- the HTTP Basic realm to use- Returns:
HttpBasicConfigurer
for additional customization
-
authenticationEntryPoint
public HttpBasicConfigurer<B> authenticationEntryPoint(AuthenticationEntryPoint authenticationEntryPoint) TheAuthenticationEntryPoint
to be populated onBasicAuthenticationFilter
in the event that authentication fails. The default to useBasicAuthenticationEntryPoint
with the realm "Realm".- Parameters:
authenticationEntryPoint
- theAuthenticationEntryPoint
to use- Returns:
HttpBasicConfigurer
for additional customization
-
authenticationDetailsSource
public HttpBasicConfigurer<B> authenticationDetailsSource(AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest, ?> authenticationDetailsSource) Specifies a customAuthenticationDetailsSource
to use for basic authentication. The default isWebAuthenticationDetailsSource
.- Parameters:
authenticationDetailsSource
- the customAuthenticationDetailsSource
to use- Returns:
HttpBasicConfigurer
for additional customization
-
securityContextRepository
public HttpBasicConfigurer<B> securityContextRepository(SecurityContextRepository securityContextRepository) Specifies a customSecurityContextRepository
to use for basic authentication. The default isRequestAttributeSecurityContextRepository
.- Parameters:
securityContextRepository
- the customSecurityContextRepository
to use- Returns:
HttpBasicConfigurer
for additional customization- Since:
- 6.1
-
init
Description copied from interface:SecurityConfigurer
Initialize theSecurityBuilder
. Here only shared state should be created and modified, but not properties on theSecurityBuilder
used 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:
init
in interfaceSecurityConfigurer<DefaultSecurityFilterChain,
B extends HttpSecurityBuilder<B>> - Overrides:
init
in classSecurityConfigurerAdapter<DefaultSecurityFilterChain,
B extends HttpSecurityBuilder<B>>
-
configure
Description copied from interface:SecurityConfigurer
Configure theSecurityBuilder
by setting the necessary properties on theSecurityBuilder
.- Specified by:
configure
in interfaceSecurityConfigurer<DefaultSecurityFilterChain,
B extends HttpSecurityBuilder<B>> - Overrides:
configure
in classSecurityConfigurerAdapter<DefaultSecurityFilterChain,
B extends HttpSecurityBuilder<B>>
-