1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Fix servlet/architecture.adoc disable Sample

- Switch `include-java` (does not exist) to `include-code`
- Update kotlin to have the `disable` tag
- Update to suppress deprecation use for User builder (allowed for samples)

Signed-off-by: Robert Winch <362503+rwinch@users.noreply.github.com>
This commit is contained in:
Robert Winch
2026-02-23 16:34:18 -06:00
parent 62d1bc86e3
commit 0c394696ce
4 changed files with 21 additions and 5 deletions
@@ -142,16 +142,16 @@ public class CustomizingFilterTests {
@EnableWebSecurity
static class SecurityConfigDisable {
// tag::disable[]
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
// tag::disable[]
.httpBasic((basic) -> basic.disable());
// end::disable[]
// ...
return http.build();
}
// end::disable[]
}
@@ -84,6 +84,7 @@ class CustomFilterTests {
open class UserDetailsConfig {
@Bean
open fun userDetailsService(): UserDetailsService {
@Suppress("DEPRECATION")
val user: UserDetails = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
@@ -26,7 +26,6 @@ import org.junit.jupiter.api.extension.ExtendWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpHeaders
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.invoke
@@ -36,7 +35,6 @@ import org.springframework.security.web.FilterChainProxy
import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.get
/**
* Tests for customizing security filters.
@@ -120,6 +118,23 @@ class CustomizingFilterTests {
}
@Configuration @EnableWebSecurity
open class SecurityConfigDisable {
// tag::disable[]
@Bean
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
http {
httpBasic {
disable()
}
// ...
}
return http.build()
}
// end::disable[]
}
@Configuration
@EnableWebSecurity
open class SecurityConfigIncorrect {