Order actuator security config after resource-server config
See gh-15472
This commit is contained in:
parent
d1e1a82b32
commit
4597e7cc82
|
|
@ -556,6 +556,16 @@
|
|||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-oauth2-resource-server</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-oauth2-jose</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -51,7 +52,8 @@ import org.springframework.security.web.server.WebFilterChainProxy;
|
|||
@AutoConfigureBefore(ReactiveSecurityAutoConfiguration.class)
|
||||
@AutoConfigureAfter({ HealthEndpointAutoConfiguration.class,
|
||||
InfoEndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class,
|
||||
ReactiveOAuth2ClientAutoConfiguration.class })
|
||||
ReactiveOAuth2ClientAutoConfiguration.class,
|
||||
ReactiveOAuth2ResourceServerAutoConfiguration.class })
|
||||
public class ReactiveManagementWebSecurityAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.WebSecurityEnablerConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
@ -47,7 +48,8 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
|||
@AutoConfigureBefore(SecurityAutoConfiguration.class)
|
||||
@AutoConfigureAfter({ HealthEndpointAutoConfiguration.class,
|
||||
InfoEndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class,
|
||||
OAuth2ClientAutoConfiguration.class })
|
||||
OAuth2ClientAutoConfiguration.class,
|
||||
OAuth2ResourceServerAutoConfiguration.class })
|
||||
@Import({ ManagementWebSecurityConfigurerAdapter.class,
|
||||
WebSecurityEnablerConfiguration.class })
|
||||
public class ManagementWebSecurityAutoConfiguration {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoC
|
|||
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext;
|
||||
|
|
@ -118,6 +119,20 @@ public class ReactiveManagementWebSecurityAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backsOffIfReactiveOAuth2ResourceServerAutoConfigurationSecurityIsAdded() {
|
||||
this.contextRunner
|
||||
.withConfiguration(AutoConfigurations
|
||||
.of(ReactiveOAuth2ResourceServerAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://authserver")
|
||||
.run((context) -> {
|
||||
assertThat(context.getBeanNamesForType(
|
||||
ReactiveManagementWebSecurityAutoConfiguration.class))
|
||||
.isEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backsOffWhenWebFilterChainProxyBeanPresent() {
|
||||
this.contextRunner.withUserConfiguration(WebFilterChainProxyConfiguration.class)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoC
|
|||
import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
|
|
@ -106,6 +107,19 @@ public class ManagementWebSecurityAutoConfigurationTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backOffIfOAuth2ResourceServerAutoConfigurationSecurityIsAdded() {
|
||||
this.contextRunner
|
||||
.withConfiguration(AutoConfigurations
|
||||
.of(OAuth2ResourceServerAutoConfiguration.class))
|
||||
.withPropertyValues(
|
||||
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://authserver")
|
||||
.run((context) -> {
|
||||
assertThat(context.getBeanNamesForType(
|
||||
ManagementWebSecurityConfigurerAdapter.class)).isEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
private HttpStatus getResponseStatus(AssertableWebApplicationContext context,
|
||||
String path) throws IOException, javax.servlet.ServletException {
|
||||
FilterChainProxy filterChainProxy = context.getBean(FilterChainProxy.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue