Revert unnecessary merges on 6.0.x
This commit removes unnecessary main-branch merges starting from8750608b5band adds the following needed commit(s) that were made afterward: -5dce82c48b
This commit is contained in:
@@ -227,11 +227,7 @@ This configuration is considered after `apiFilterChain`, since it has an `@Order
|
||||
|
||||
You can provide your own custom DSLs in Spring Security:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,role="primary"]
|
||||
[source,java]
|
||||
----
|
||||
public class MyCustomDsl extends AbstractHttpConfigurer<MyCustomDsl, HttpSecurity> {
|
||||
private boolean flag;
|
||||
@@ -264,38 +260,6 @@ public class MyCustomDsl extends AbstractHttpConfigurer<MyCustomDsl, HttpSecurit
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
class MyCustomDsl : AbstractHttpConfigurer<MyCustomDsl, HttpSecurity>() {
|
||||
var flag: Boolean = false
|
||||
|
||||
override fun init(http: HttpSecurity) {
|
||||
// any method that adds another configurer
|
||||
// must be done in the init method
|
||||
http.csrf().disable()
|
||||
}
|
||||
|
||||
override fun configure(http: HttpSecurity) {
|
||||
val context: ApplicationContext = http.getSharedObject(ApplicationContext::class.java)
|
||||
|
||||
// here we lookup from the ApplicationContext. You can also just create a new instance.
|
||||
val myFilter: MyFilter = context.getBean(MyFilter::class.java)
|
||||
myFilter.setFlag(flag)
|
||||
http.addFilterBefore(myFilter, UsernamePasswordAuthenticationFilter::class.java)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun customDsl(): MyCustomDsl {
|
||||
return MyCustomDsl()
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
This is actually how methods like `HttpSecurity.authorizeRequests()` are implemented.
|
||||
@@ -303,11 +267,7 @@ This is actually how methods like `HttpSecurity.authorizeRequests()` are impleme
|
||||
|
||||
You can then use the custom DSL:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,role="primary"]
|
||||
[source,java]
|
||||
----
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@@ -315,37 +275,15 @@ public class Config {
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.with(MyCustomDsl.customDsl(), (dsl) -> dsl
|
||||
.apply(customDsl())
|
||||
.flag(true)
|
||||
)
|
||||
// ...
|
||||
.and()
|
||||
...;
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
class Config {
|
||||
|
||||
@Bean
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||
http
|
||||
.with(MyCustomDsl.customDsl()) {
|
||||
flag = true
|
||||
}
|
||||
// ...
|
||||
|
||||
return http.build()
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
The code is invoked in the following order:
|
||||
|
||||
* Code in the `Config.filterChain` method is invoked
|
||||
@@ -363,50 +301,21 @@ org.springframework.security.config.annotation.web.configurers.AbstractHttpConfi
|
||||
|
||||
You can also explicit disable the default:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,role="primary"]
|
||||
[source,java]
|
||||
----
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class Config {
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.with(MyCustomDsl.customDsl(), (dsl) -> dsl
|
||||
.disable()
|
||||
)
|
||||
.apply(customDsl()).disable()
|
||||
...;
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
class Config {
|
||||
|
||||
@Bean
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||
http
|
||||
.with(MyCustomDsl.customDsl()) {
|
||||
disable()
|
||||
}
|
||||
// ...
|
||||
return http.build()
|
||||
}
|
||||
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
[[post-processing-configured-objects]]
|
||||
== Post Processing Configured Objects
|
||||
|
||||
|
||||
Reference in New Issue
Block a user