Summary
This will allow defaulting the HttpSecurity if no instances were created
Comment From: ibaskine
@rwinch This your fix created funny problem for me. I use XML-based configuration, for reasons too long to explain. I also use several authentication managers within my configuration, for reasons even longer to explain. After upgrading spring security to 5.X I am getting an exception shown below. This is happening because component scan encounters HttpSecurityConfiguration class and tries to create it's definition. As the authenticationManager is declared as required it tries to auto-wire AuthenticationManager. As there are more then one authentication manager available auto-wire attempt fails,
I don't need the HttpSecurityConfiguration in my application, but I could not find the way to exclude it from component scan as the class is of package level,
Here is the exception. Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available: expected single matching bean but found 4: org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.authenticationManager,stdProviderManager at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:220) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1345) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:714) ... 60 more
Comment From: rwinch
@ibaskine Can you please create a new ticket rather than commenting on an old ticket?
Comment From: ibaskine
I created a ticket in Spring Security (https://github.com/spring-projects/spring-security/issues/9256)