Describe the bug When the debug option is enabled with @EnableWebSecurity(debug = true), an error occurs. I haven't done anything beyond this configuration. I simply enabled the debug option. Here is the link for reference: https://docs.spring.io/spring-security/reference/servlet/authentication/passwords/index.html
To Reproduce Steps to reproduce the behavior.
build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'me.choicore.demo'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '21'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
tasks.named('test') {
useJUnitPlatform()
}
Security Configurer
@Configuration
@EnableWebSecurity(debug = true)
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.httpBasic(Customizer.withDefaults())
.formLogin(Customizer.withDefaults());
return http.build();
}
@Bean
public UserDetailsService userDetailsService() {
UserDetails userDetails = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(userDetails);
}
}
Expected behavior
When the debug option is disabled, it starts up normally.
Sample
There's no sample code as it's quite simple. Please check the above configuration.
Comment From: kse-music
Fixed in latest version,https://github.com/spring-projects/spring-security/issues/14370
Comment From: jzheaux
Thanks, @CHOICORE. I think this is a duplicate of #14370, as @kse-music reported.