Class CorsConfigurer<H extends HttpSecurityBuilder<H>>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, H>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<CorsConfigurer<H>, H>
org.springframework.security.config.annotation.web.configurers.CorsConfigurer<H>
- Type Parameters:
H- the builder to return.
- All Implemented Interfaces:
SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, H>
public class CorsConfigurer<H extends HttpSecurityBuilder<H>>
extends AbstractHttpConfigurer<CorsConfigurer<H>, H>
Adds
CorsFilter or PreFlightRequestFilter to the Spring Security filter
chain. If a bean by the name of corsFilter is provided, that CorsFilter is
used. Else if corsConfigurationSource is defined, then that
CorsConfigurationSource is used. If a PreFlightRequestHandler is set on
this configurer, CorsFilter is not used and PreFlightRequestFilter is
registered instead.- Since:
- 4.1.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconfigurationSource(org.springframework.web.cors.CorsConfigurationSource configurationSource) voidConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.preFlightRequestHandler(org.springframework.web.cors.PreFlightRequestHandler preFlightRequestHandler) Use the givenPreFlightRequestHandlerfor CORS preflight requests.Methods inherited from class AbstractHttpConfigurer
disable, getRequestMatcherBuilder, getSecurityContextHolderStrategy, withObjectPostProcessorMethods inherited from class SecurityConfigurerAdapter
addObjectPostProcessor, getBuilder, init, postProcess, setBuilder
-
Constructor Details
-
CorsConfigurer
public CorsConfigurer()Creates a new instance- See Also:
-
-
Method Details
-
configurationSource
public CorsConfigurer<H> configurationSource(org.springframework.web.cors.CorsConfigurationSource configurationSource) -
preFlightRequestHandler
public CorsConfigurer<H> preFlightRequestHandler(org.springframework.web.cors.PreFlightRequestHandler preFlightRequestHandler) Use the givenPreFlightRequestHandlerfor CORS preflight requests. When set,CorsFilteris not used. Cannot be combined withconfigurationSource(CorsConfigurationSource).- Parameters:
preFlightRequestHandler- the handler to use- Returns:
- the
CorsConfigurerfor additional configuration
-
configure
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain, H extends HttpSecurityBuilder<H>>- Overrides:
configurein classSecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain, H extends HttpSecurityBuilder<H>>- Parameters:
http-
-