From b85ec4de1aea736cf84c3d7d6a707a7e4a79adde Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Wed, 17 Aug 2022 23:16:39 +0200 Subject: [PATCH] Fix Spring Security configuration in tests As of spring-projects/spring-security#11653, Spring Security's [at]Enable*Security annotations are not meta annotated with [at]Configuration which breaks some of our tests. This commit adds missing [at]Configuration annotations where needed. Closes gh-2118 --- .../MongoDbDeleteJacksonSessionVerificationTest.java | 3 ++- .../data/mongo/integration/MongoDbLogoutVerificationTest.java | 3 ++- .../java/docs/security/RememberMeSecurityConfiguration.java | 4 +++- .../src/main/java/sample/SecurityConfig.java | 4 +++- .../src/main/java/sample/SecurityConfig.java | 4 +++- .../src/main/java/sample/SecurityConfig.java | 4 +++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbDeleteJacksonSessionVerificationTest.java b/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbDeleteJacksonSessionVerificationTest.java index 4719a9cc6..f06ad0caf 100644 --- a/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbDeleteJacksonSessionVerificationTest.java +++ b/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbDeleteJacksonSessionVerificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2014-2022 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. @@ -137,6 +137,7 @@ ResponseEntity hello() { } + @Configuration(proxyBeanMethods = false) @EnableWebFluxSecurity static class SecurityConfig { diff --git a/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbLogoutVerificationTest.java b/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbLogoutVerificationTest.java index 4320a3ea2..3a061c716 100644 --- a/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbLogoutVerificationTest.java +++ b/spring-session-data-mongodb/src/integration-test/java/org/springframework/session/data/mongo/integration/MongoDbLogoutVerificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2014-2022 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. @@ -135,6 +135,7 @@ ResponseEntity hello() { } + @Configuration(proxyBeanMethods = false) @EnableWebFluxSecurity static class SecurityConfig { diff --git a/spring-session-docs/modules/ROOT/examples/java/docs/security/RememberMeSecurityConfiguration.java b/spring-session-docs/modules/ROOT/examples/java/docs/security/RememberMeSecurityConfiguration.java index d8061e30e..d0feff640 100644 --- a/spring-session-docs/modules/ROOT/examples/java/docs/security/RememberMeSecurityConfiguration.java +++ b/spring-session-docs/modules/ROOT/examples/java/docs/security/RememberMeSecurityConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -32,6 +33,7 @@ /** * @author rwinch */ +@Configuration(proxyBeanMethods = false) @EnableWebSecurity @EnableSpringHttpSession public class RememberMeSecurityConfiguration extends WebSecurityConfigurerAdapter { diff --git a/spring-session-samples/spring-session-sample-javaconfig-hazelcast/src/main/java/sample/SecurityConfig.java b/spring-session-samples/spring-session-sample-javaconfig-hazelcast/src/main/java/sample/SecurityConfig.java index 41acbae6a..3c9711476 100644 --- a/spring-session-samples/spring-session-sample-javaconfig-hazelcast/src/main/java/sample/SecurityConfig.java +++ b/spring-session-samples/spring-session-sample-javaconfig-hazelcast/src/main/java/sample/SecurityConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -17,6 +17,7 @@ package sample; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.core.userdetails.User; @@ -24,6 +25,7 @@ /** * @author Rob Winch */ +@Configuration(proxyBeanMethods = false) @EnableWebSecurity public class SecurityConfig { diff --git a/spring-session-samples/spring-session-sample-javaconfig-rest/src/main/java/sample/SecurityConfig.java b/spring-session-samples/spring-session-sample-javaconfig-rest/src/main/java/sample/SecurityConfig.java index 6a2ecf46d..2e5490d11 100644 --- a/spring-session-samples/spring-session-sample-javaconfig-rest/src/main/java/sample/SecurityConfig.java +++ b/spring-session-samples/spring-session-sample-javaconfig-rest/src/main/java/sample/SecurityConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -17,6 +17,7 @@ package sample; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -25,6 +26,7 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.web.savedrequest.NullRequestCache; +@Configuration(proxyBeanMethods = false) @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { diff --git a/spring-session-samples/spring-session-sample-javaconfig-security/src/main/java/sample/SecurityConfig.java b/spring-session-samples/spring-session-sample-javaconfig-security/src/main/java/sample/SecurityConfig.java index 41acbae6a..3c9711476 100644 --- a/spring-session-samples/spring-session-sample-javaconfig-security/src/main/java/sample/SecurityConfig.java +++ b/spring-session-samples/spring-session-sample-javaconfig-security/src/main/java/sample/SecurityConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 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. @@ -17,6 +17,7 @@ package sample; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.core.userdetails.User; @@ -24,6 +25,7 @@ /** * @author Rob Winch */ +@Configuration(proxyBeanMethods = false) @EnableWebSecurity public class SecurityConfig {