IllegalStateException: Found WebSecurityConfigurerAdapter as well as SecurityFilterChain. Please select just one.
See original GitHub issueDescription
The ProblemSecurityAutoConfiguration registers a WebSecurityConfigurerAdapter
and causes this issue when combined with the spring-boot-security-starter
causes https://github.com/spring-projects/spring-security/issues/9295.
Expected Behavior
Exception above.
Actual Behavior
Register configurer if and only if we don’t interfere with the default.
Possible Fix
Steps to Reproduce
Context
Your Environment
- Version used:
- Link to your project:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:15 (1 by maintainers)
Top Results From Across the Web
spring - Caused by: java.lang.IllegalStateException: Found ...
Caused by: java.lang.IllegalStateException: Found WebSecurityConfigurerAdapter as well as SecurityFilterChain. Please select just one · Ask ...
Read more >How to Fix WebSecurityConfigurerAdapter Deprecated
How to update Spring Security configuration class to remove the warning The type WebSecurityConfigurerAdapter is deprecated.
Read more >Spring Security without the WebSecurityConfigurerAdapter
Configuring HttpSecurity. In Spring Security 5.4 we introduced the ability to configure HttpSecurity by creating a SecurityFilterChain bean.
Read more >Spring Boot Security Auto-Configuration - Baeldung
A quick and practical guide to Spring Boot's default Spring Security configuration.
Read more >[Fixed] Spring Security WebSecurityConfigurerAdapter ...
Guide to fix the warning message "The type WebSecurityConfigurerAdapter is deprecated" in a Spring Boot application using Spring Security.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is how I managed to get a working test but I had to manually configure the Problem Security support (so I don’t like the solution at all):
SpringSecurityExceptionTest.java
Sample test to show the problem:
pom.xml
SpringSecurityExceptionTest.java
The tests pass.
If I add
problem-spring-web
:pom.xml
Same
SpringSecurityExceptionTest.java
as before.The Spring context can’t be build.
If I exclude the
ProblemSecurityAutoConfiguration
and adapt the expected json respone check for thetestAccessDenied()
:The
testAccessDenied()
do not pass as an error 500 is issued (instead of the expected 403).