diff --git a/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfiguration.java
index 512361b38f..2704ca6d4d 100644
--- a/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfiguration.java
+++ b/config/src/main/java/org/springframework/security/config/annotation/authentication/configuration/AuthenticationConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,8 +107,7 @@ public class AuthenticationConfiguration {
if (this.authenticationManagerInitialized) {
return this.authenticationManager;
}
- AuthenticationManagerBuilder authBuilder = authenticationManagerBuilder(
- this.objectPostProcessor, this.applicationContext);
+ AuthenticationManagerBuilder authBuilder = this.applicationContext.getBean(AuthenticationManagerBuilder.class);
if (this.buildingAuthenticationManager.getAndSet(true)) {
return new AuthenticationManagerDelegator(authBuilder);
}
diff --git a/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java
index 1139119251..38925a45d0 100644
--- a/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java
+++ b/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.AdviceMode;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.ImportAware;
+import org.springframework.context.annotation.*;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.type.AnnotationMetadata;
@@ -110,7 +107,6 @@ public class GlobalMethodSecurityConfiguration
*
{@link #accessDecisionManager()}
*
{@link #afterInvocationManager()}
*
{@link #authenticationManager()}
- *
{@link #methodSecurityMetadataSource()}
*
{@link #runAsManager()}
*
*
@@ -119,19 +115,19 @@ public class GlobalMethodSecurityConfiguration
* Subclasses can override this method to provide a different
* {@link MethodInterceptor}.
*
+ * @param methodSecurityMetadataSource the default {@link MethodSecurityMetadataSource}.
*
* @return the {@link MethodInterceptor}.
- * @throws Exception
*/
@Bean
- public MethodInterceptor methodSecurityInterceptor() throws Exception {
+ public MethodInterceptor methodSecurityInterceptor(MethodSecurityMetadataSource methodSecurityMetadataSource) {
this.methodSecurityInterceptor = isAspectJ()
? new AspectJMethodSecurityInterceptor()
: new MethodSecurityInterceptor();
methodSecurityInterceptor.setAccessDecisionManager(accessDecisionManager());
methodSecurityInterceptor.setAfterInvocationManager(afterInvocationManager());
methodSecurityInterceptor
- .setSecurityMetadataSource(methodSecurityMetadataSource());
+ .setSecurityMetadataSource(methodSecurityMetadataSource);
RunAsManager runAsManager = runAsManager();
if (runAsManager != null) {
methodSecurityInterceptor.setRunAsManager(runAsManager);
@@ -197,8 +193,8 @@ public class GlobalMethodSecurityConfiguration
/**
* Provide a custom {@link AfterInvocationManager} for the default implementation of
- * {@link #methodSecurityInterceptor()}. The default is null if pre post is not
- * enabled. Otherwise, it returns a {@link AfterInvocationProviderManager}.
+ * {@link #methodSecurityInterceptor(MethodSecurityMetadataSource)}. The default is null
+ * if pre post is not enabled. Otherwise, it returns a {@link AfterInvocationProviderManager}.
*
*
* Subclasses should override this method to provide a custom
@@ -224,7 +220,7 @@ public class GlobalMethodSecurityConfiguration
/**
* Provide a custom {@link RunAsManager} for the default implementation of
- * {@link #methodSecurityInterceptor()}. The default is null.
+ * {@link #methodSecurityInterceptor(MethodSecurityMetadataSource)}. The default is null.
*
* @return the {@link RunAsManager} to use
*/
diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfiguration.java
index 1cc17fed54..a0d9084b6f 100644
--- a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfiguration.java
+++ b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfiguration.java
@@ -43,7 +43,7 @@ import org.springframework.web.reactive.result.method.annotation.ArgumentResolve
* @since 5.0
*/
@Configuration
-class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
+class ServerHttpSecurityConfiguration {
private static final String BEAN_NAME_PREFIX = "org.springframework.security.config.annotation.web.reactive.HttpSecurityConfiguration.";
private static final String HTTPSECURITY_BEAN_NAME = BEAN_NAME_PREFIX + "httpSecurity";
@@ -85,9 +85,15 @@ class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
this.userDetailsPasswordService = userDetailsPasswordService;
}
- @Override
- public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
- configurer.addCustomResolver(authenticationPrincipalArgumentResolver());
+ @Bean
+ public WebFluxConfigurer authenticationPrincipalArgumentResolverConfigurer(
+ AuthenticationPrincipalArgumentResolver authenticationPrincipalArgumentResolver) {
+ return new WebFluxConfigurer() {
+ @Override
+ public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
+ configurer.addCustomResolver(authenticationPrincipalArgumentResolver);
+ }
+ };
}
@Bean
@@ -110,7 +116,6 @@ class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
return resolver;
}
-
@Bean(HTTPSECURITY_BEAN_NAME)
@Scope("prototype")
public ServerHttpSecurity httpSecurity() {
diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurer.java
index d3b2de2709..42c560af68 100644
--- a/config/src/main/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurer.java
+++ b/config/src/main/java/org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,10 +103,10 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
@Override
public final void configureClientInboundChannel(ChannelRegistration registration) {
- ChannelSecurityInterceptor inboundChannelSecurity = inboundChannelSecurity();
- registration.setInterceptors(securityContextChannelInterceptor());
+ ChannelSecurityInterceptor inboundChannelSecurity = context.getBean(ChannelSecurityInterceptor.class);
+ registration.setInterceptors(context.getBean(SecurityContextChannelInterceptor.class));
if (!sameOriginDisabled()) {
- registration.setInterceptors(csrfChannelInterceptor());
+ registration.setInterceptors(context.getBean(CsrfChannelInterceptor.class));
}
if (inboundRegistry.containsMapping()) {
registration.setInterceptors(inboundChannelSecurity);
@@ -153,9 +153,9 @@ public abstract class AbstractSecurityWebSocketMessageBrokerConfigurer extends
}
@Bean
- public ChannelSecurityInterceptor inboundChannelSecurity() {
+ public ChannelSecurityInterceptor inboundChannelSecurity(MessageSecurityMetadataSource messageSecurityMetadataSource) {
ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(
- inboundMessageSecurityMetadataSource());
+ messageSecurityMetadataSource);
MessageExpressionVoter