mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Updated the Configuration examples in docs
Closes gh-14384
This commit is contained in:
parent
79eef6cc54
commit
e11ed2d313
@ -173,7 +173,7 @@ It is configured with the following default implementation:
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.authorizeRequests(authorize -> authorize
|
.authorizeHttpRequests(authorize -> authorize
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
@ -290,7 +290,7 @@ public class MyCustomDsl extends AbstractHttpConfigurer<MyCustomDsl, HttpSecurit
|
|||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
This is actually how methods like `HttpSecurity.authorizeRequests()` are implemented.
|
This is actually how methods like `HttpSecurity.authorizeHttpRequests()` are implemented.
|
||||||
====
|
====
|
||||||
|
|
||||||
You can then use the custom DSL:
|
You can then use the custom DSL:
|
||||||
@ -360,7 +360,7 @@ For example, to configure the `filterSecurityPublishAuthorizationSuccess` proper
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.authorizeRequests(authorize -> authorize
|
.authorizeHttpRequests(authorize -> authorize
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
|
.withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
|
||||||
public <O extends FilterSecurityInterceptor> O postProcess(
|
public <O extends FilterSecurityInterceptor> O postProcess(
|
||||||
|
@ -24,7 +24,7 @@ import org.springframework.security.config.annotation.web.invoke
|
|||||||
@Bean
|
@Bean
|
||||||
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeRequests {
|
authorizeHttpRequests {
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
formLogin { }
|
formLogin { }
|
||||||
@ -81,7 +81,7 @@ class MultiHttpSecurityConfig {
|
|||||||
open fun apiFilterChain(http: HttpSecurity): SecurityFilterChain {
|
open fun apiFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
securityMatcher("/api/**") <3>
|
securityMatcher("/api/**") <3>
|
||||||
authorizeRequests {
|
authorizeHttpRequests {
|
||||||
authorize(anyRequest, hasRole("ADMIN"))
|
authorize(anyRequest, hasRole("ADMIN"))
|
||||||
}
|
}
|
||||||
httpBasic { }
|
httpBasic { }
|
||||||
@ -92,7 +92,7 @@ class MultiHttpSecurityConfig {
|
|||||||
@Bean <4>
|
@Bean <4>
|
||||||
open fun formLoginFilterChain(http: HttpSecurity): SecurityFilterChain {
|
open fun formLoginFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
http {
|
http {
|
||||||
authorizeRequests {
|
authorizeHttpRequests {
|
||||||
authorize(anyRequest, authenticated)
|
authorize(anyRequest, authenticated)
|
||||||
}
|
}
|
||||||
formLogin { }
|
formLogin { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user