|
20 | 20 | import org.junit.Test;
|
21 | 21 | import org.springframework.beans.factory.annotation.Autowired;
|
22 | 22 | import org.springframework.context.annotation.Bean;
|
| 23 | +import org.springframework.context.annotation.Import; |
| 24 | +import org.springframework.context.annotation.ImportResource; |
23 | 25 | import org.springframework.core.Ordered;
|
24 | 26 | import org.springframework.core.annotation.Order;
|
25 | 27 | import org.springframework.core.io.buffer.DataBuffer;
|
26 | 28 | import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
27 | 29 | import org.springframework.security.authentication.TestingAuthenticationToken;
|
28 | 30 | import org.springframework.security.config.test.SpringTestRule;
|
| 31 | +import org.springframework.security.config.users.ReactiveAuthenticationTestConfiguration; |
29 | 32 | import org.springframework.security.config.web.server.ServerHttpSecurity;
|
30 | 33 | import org.springframework.security.core.Authentication;
|
31 | 34 | import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
|
@@ -141,15 +144,8 @@ public void defaultPopulatesReactorContextWhenAuthenticating() {
|
141 | 144 | }
|
142 | 145 |
|
143 | 146 | @EnableWebFluxSecurity
|
| 147 | + @Import(ReactiveAuthenticationTestConfiguration.class) |
144 | 148 | static class Config {
|
145 |
| - @Bean |
146 |
| - public ReactiveUserDetailsService userDetailsRepository() { |
147 |
| - return new MapReactiveUserDetailsService(User.withUsername("user") |
148 |
| - .password("password") |
149 |
| - .roles("USER") |
150 |
| - .build() |
151 |
| - ); |
152 |
| - } |
153 | 149 | }
|
154 | 150 |
|
155 | 151 | @Test
|
@@ -236,22 +232,21 @@ public void multiWorks() {
|
236 | 232 | }
|
237 | 233 |
|
238 | 234 | @EnableWebFluxSecurity
|
| 235 | + @Import(ReactiveAuthenticationTestConfiguration.class) |
239 | 236 | static class MultiSecurityHttpConfig {
|
240 |
| - @Order(Ordered.HIGHEST_PRECEDENCE) @Bean public SecurityWebFilterChain apiHttpSecurity( |
| 237 | + @Order(Ordered.HIGHEST_PRECEDENCE) |
| 238 | + @Bean |
| 239 | + public SecurityWebFilterChain apiHttpSecurity( |
241 | 240 | ServerHttpSecurity http) {
|
242 | 241 | http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**"))
|
243 | 242 | .authorizeExchange().anyExchange().denyAll();
|
244 | 243 | return http.build();
|
245 | 244 | }
|
246 | 245 |
|
247 |
| - @Bean public SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) { |
| 246 | + @Bean |
| 247 | + public SecurityWebFilterChain httpSecurity(ServerHttpSecurity http) { |
248 | 248 | return http.build();
|
249 | 249 | }
|
250 |
| - |
251 |
| - @Bean public ReactiveUserDetailsService userDetailsRepository() { |
252 |
| - return new MapReactiveUserDetailsService( |
253 |
| - User.withUsername("user").password("password").roles("USER").build()); |
254 |
| - } |
255 | 250 | }
|
256 | 251 |
|
257 | 252 | private static DataBuffer toDataBuffer(String body) {
|
|
0 commit comments