Skip to content

Commit 50f3c48

Browse files
Making UserDetailsServiceAutoConfiguration conditional
The UserDetailsServiceAutoConfiguration is only to be active in a servlet based web application See gh-43326
1 parent 4ee9fae commit 50f3c48

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3232
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
3333
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
34+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
35+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
3436
import org.springframework.boot.autoconfigure.security.SecurityProperties;
3537
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration.MissingAlternativeOrUserPropertiesConfigured;
3638
import org.springframework.context.annotation.Bean;
@@ -53,6 +55,7 @@
5355
* @author Dave Syer
5456
* @author Rob Winch
5557
* @author Madhura Bhave
58+
* @author Lasse Wulff
5659
* @since 2.0.0
5760
*/
5861
@AutoConfiguration
@@ -61,6 +64,7 @@
6164
@ConditionalOnBean(ObjectPostProcessor.class)
6265
@ConditionalOnMissingBean(value = { AuthenticationManager.class, AuthenticationProvider.class, UserDetailsService.class,
6366
AuthenticationManagerResolver.class }, type = "org.springframework.security.oauth2.jwt.JwtDecoder")
67+
@ConditionalOnWebApplication(type = Type.SERVLET)
6468
public class UserDetailsServiceAutoConfiguration {
6569

6670
private static final String NOOP_PASSWORD_PREFIX = "{noop}";

0 commit comments

Comments
 (0)