|
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanFactoryUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.bootstrap.actuate.properties.EndpointsProperties;
|
|
|
|
|
import org.springframework.bootstrap.actuate.properties.SecurityProperties;
|
|
|
|
@ -28,16 +27,11 @@ import org.springframework.bootstrap.context.annotation.ConditionalOnClass;
|
|
|
|
|
import org.springframework.bootstrap.context.annotation.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.bootstrap.context.annotation.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Condition;
|
|
|
|
|
import org.springframework.context.annotation.ConditionContext;
|
|
|
|
|
import org.springframework.context.annotation.Conditional;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
|
|
|
|
import org.springframework.security.authentication.AuthenticationEventPublisher;
|
|
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
|
|
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
|
|
|
|
|
import org.springframework.security.authentication.ProviderManager;
|
|
|
|
|
import org.springframework.security.config.BeanIds;
|
|
|
|
|
import org.springframework.security.config.annotation.authentication.AuthenticationManagerBuilder;
|
|
|
|
|
import org.springframework.security.config.annotation.web.EnableWebSecurity;
|
|
|
|
|
import org.springframework.security.config.annotation.web.HttpConfiguration;
|
|
|
|
@ -149,7 +143,7 @@ public class SecurityAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Conditional(NoUserSuppliedAuthenticationManager.class)
|
|
|
|
|
@ConditionalOnMissingBean(AuthenticationManager.class)
|
|
|
|
|
@Configuration
|
|
|
|
|
public static class AuthenticationManagerConfiguration {
|
|
|
|
|
|
|
|
|
@ -162,21 +156,4 @@ public class SecurityAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class NoUserSuppliedAuthenticationManager implements Condition {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
|
|
|
|
String[] beans = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
|
|
|
|
context.getBeanFactory(), AuthenticationManager.class, false, false);
|
|
|
|
|
for (String bean : beans) {
|
|
|
|
|
if (!BeanIds.AUTHENTICATION_MANAGER.equals(bean)) {
|
|
|
|
|
// Not the one supplied by Spring Security automatically
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|