diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurity.java b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurity.java index c5a52af35d..a4f75ee1ec 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurity.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurity.java @@ -38,7 +38,7 @@ import java.lang.annotation.Target; * public class MyMinimalSecurityConfiguration { * * @Bean - * public MapReactiveUserDetailsService userDetailsRepository() { + * public MapReactiveUserDetailsService userDetailsService() { * UserDetails user = User.withDefaultPasswordEncoder() * .username("user") * .password("password") @@ -66,7 +66,7 @@ import java.lang.annotation.Target; * } * * @Bean - * public MapReactiveUserDetailsService userDetailsRepository() { + * public MapReactiveUserDetailsService userDetailsService() { * UserDetails user = User.withDefaultPasswordEncoder() * .username("user") * .password("password") diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java index dd67d3878d..a67821ec85 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java @@ -212,7 +212,7 @@ public class EnableWebFluxSecurityTests { @EnableWebFluxSecurity static class CustomPasswordEncoderConfig { @Bean - public ReactiveUserDetailsService userDetailsRepository(PasswordEncoder encoder) { + public ReactiveUserDetailsService userDetailsService(PasswordEncoder encoder) { return new MapReactiveUserDetailsService(User.withUsername("user") .password(encoder.encode("password")) .roles("USER") diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationBuilder.java b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationBuilder.java index aa43f5de60..712bce13a8 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationBuilder.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationBuilder.java @@ -33,7 +33,7 @@ public class ServerHttpSecurityConfigurationBuilder { public static ServerHttpSecurity httpWithDefaultAuthentication() { ReactiveUserDetailsService reactiveUserDetailsService = ReactiveAuthenticationTestConfiguration - .userDetailsRepository(); + .userDetailsService(); ReactiveAuthenticationManager authenticationManager = new UserDetailsRepositoryReactiveAuthenticationManager( reactiveUserDetailsService); return http() diff --git a/config/src/test/java/org/springframework/security/config/users/ReactiveAuthenticationTestConfiguration.java b/config/src/test/java/org/springframework/security/config/users/ReactiveAuthenticationTestConfiguration.java index 42d163aded..ce12541c3b 100644 --- a/config/src/test/java/org/springframework/security/config/users/ReactiveAuthenticationTestConfiguration.java +++ b/config/src/test/java/org/springframework/security/config/users/ReactiveAuthenticationTestConfiguration.java @@ -29,7 +29,7 @@ import org.springframework.security.core.userdetails.ReactiveUserDetailsService; @Configuration public class ReactiveAuthenticationTestConfiguration { @Bean - public static ReactiveUserDetailsService userDetailsRepository() { + public static ReactiveUserDetailsService userDetailsService() { return new MapReactiveUserDetailsService(PasswordEncodedUser.user(), PasswordEncodedUser.admin()); } } diff --git a/core/src/main/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManager.java b/core/src/main/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManager.java index 303fcb627e..ed062e142e 100644 --- a/core/src/main/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManager.java +++ b/core/src/main/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManager.java @@ -30,19 +30,19 @@ import reactor.core.scheduler.Schedulers; * @since 5.0 */ public class UserDetailsRepositoryReactiveAuthenticationManager implements ReactiveAuthenticationManager { - private final ReactiveUserDetailsService repository; + private final ReactiveUserDetailsService userDetailsService; private PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder(); - public UserDetailsRepositoryReactiveAuthenticationManager(ReactiveUserDetailsService reactiveUserDetailsService) { - Assert.notNull(reactiveUserDetailsService, "userDetailsRepository cannot be null"); - this.repository = reactiveUserDetailsService; + public UserDetailsRepositoryReactiveAuthenticationManager(ReactiveUserDetailsService userDetailsService) { + Assert.notNull(userDetailsService, "userDetailsService cannot be null"); + this.userDetailsService = userDetailsService; } @Override public Mono authenticate(Authentication authentication) { final String username = authentication.getName(); - return this.repository.findByUsername(username) + return this.userDetailsService.findByUsername(username) .publishOn(Schedulers.parallel()) .filter( u -> this.passwordEncoder.matches((String) authentication.getCredentials(), u.getPassword())) .switchIfEmpty( Mono.error(new BadCredentialsException("Invalid Credentials")) ) diff --git a/core/src/test/java/org/springframework/security/authentication/ReactiveUserDetailsServiceAuthenticationManagerTests.java b/core/src/test/java/org/springframework/security/authentication/ReactiveUserDetailsServiceAuthenticationManagerTests.java index 3abb55a6f3..2b892367c0 100644 --- a/core/src/test/java/org/springframework/security/authentication/ReactiveUserDetailsServiceAuthenticationManagerTests.java +++ b/core/src/test/java/org/springframework/security/authentication/ReactiveUserDetailsServiceAuthenticationManagerTests.java @@ -56,9 +56,9 @@ public class ReactiveUserDetailsServiceAuthenticationManagerTests { } @Test(expected = IllegalArgumentException.class) - public void constructorNullUserDetailsRepository() { - ReactiveUserDetailsService udr = null; - new UserDetailsRepositoryReactiveAuthenticationManager(udr); + public void constructorNullUserDetailsService() { + ReactiveUserDetailsService userDetailsService = null; + new UserDetailsRepositoryReactiveAuthenticationManager(userDetailsService); } @Test diff --git a/docs/manual/src/docs/asciidoc/index.adoc b/docs/manual/src/docs/asciidoc/index.adoc index 7b9493b4ed..46c3d2fc27 100644 --- a/docs/manual/src/docs/asciidoc/index.adoc +++ b/docs/manual/src/docs/asciidoc/index.adoc @@ -825,7 +825,7 @@ You can find a minimal WebFlux Security configuration below: public class HelloWebfluxSecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("user") @@ -850,7 +850,7 @@ You can find an explicit version of the minimal WebFlux Security configuration b public class HelloWebfluxSecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("user") @@ -1750,7 +1750,7 @@ Below is a minimal method security configuration when using method security in r @EnableReactiveMethodSecurity public class SecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { User.UserBuilder userBuilder = User.withDefaultPasswordEncoder(); UserDetails rob = userBuilder.username("rob").password("rob").roles("USER").build(); UserDetails admin = userBuilder.username("admin").password("admin").roles("USER","ADMIN").build(); @@ -1798,7 +1798,7 @@ public class SecurityConfig { } @Bean - MapReactiveUserDetailsService userDetailsRepository() { + MapReactiveUserDetailsService userDetailsService() { User.UserBuilder userBuilder = User.withDefaultPasswordEncoder(); UserDetails rob = userBuilder.username("rob").password("rob").roles("USER").build(); UserDetails admin = userBuilder.username("admin").password("admin").roles("USER","ADMIN").build(); diff --git a/samples/javaconfig/hellowebflux-method/src/main/java/sample/SecurityConfig.java b/samples/javaconfig/hellowebflux-method/src/main/java/sample/SecurityConfig.java index 27cff1b33e..24315930df 100644 --- a/samples/javaconfig/hellowebflux-method/src/main/java/sample/SecurityConfig.java +++ b/samples/javaconfig/hellowebflux-method/src/main/java/sample/SecurityConfig.java @@ -46,7 +46,7 @@ public class SecurityConfig { } @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { User.UserBuilder userBuilder = User.withDefaultPasswordEncoder(); UserDetails rob = userBuilder.username("rob").password("rob").roles("USER").build(); UserDetails admin = userBuilder.username("admin").password("admin").roles("USER", "ADMIN").build(); diff --git a/samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java b/samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java index 474eb463de..52cf27abd7 100644 --- a/samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java +++ b/samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java @@ -30,7 +30,7 @@ import org.springframework.security.core.userdetails.UserDetails; public class HelloWebfluxSecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("user") diff --git a/samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java b/samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java index 3168162dca..881d8063da 100644 --- a/samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java +++ b/samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java @@ -30,7 +30,7 @@ import org.springframework.security.core.userdetails.UserDetails; public class HelloWebfluxFnSecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("user") diff --git a/samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java b/samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java index 4d19048b1a..60bfc9495c 100644 --- a/samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java +++ b/samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java @@ -32,7 +32,7 @@ import org.springframework.security.web.server.SecurityWebFilterChain; public class WebfluxFormSecurityConfig { @Bean - public MapReactiveUserDetailsService userDetailsRepository() { + public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("password")