Java 类org.springframework.security.core.userdetails.ReactiveUserDetailsService 实例源码

项目:AngularAndSpring    文件:WebfluxSecurityConfig.java   
@Bean
public ReactiveUserDetailsService userDetailsRepository() {
    return new ReactiveUserDetailsService() {

        @Override
        public Mono<UserDetails> findByUsername(String username) {
            Query query = new Query();
            query.addCriteria(Criteria.where("userId").is(username));
            return operations.findOne(query, UserDetails.class);
        }
    };
}
项目:configurable-single-user-spring-boot-starter    文件:UserDetailsServiceConfigurationTest.java   
@Test
public void configuresADefaultUser() {
    contextRunner
            .withPropertyValues("singleuser.name=michael")
            .withConfiguration(AutoConfigurations.of(SecurityAutoConfiguration.class, SingleUserAutoConfiguration.class))
            .run(context -> {
                assertThat(context.getBean(UserDetailsService.class).loadUserByUsername("michael")).isNotNull();
                assertThat(context).getBean(ReactiveUserDetailsService.class).isNull();
            });
}
项目:configurable-single-user-spring-boot-starter    文件:ReactiveUserDetailsServiceConfigurationTest.java   
@Test
public void configuresADefaultUser() {

    contextRunner
            .withUserConfiguration(TestConfig.class)
            .withPropertyValues("singleuser.name=michael")
            .withConfiguration(AutoConfigurations.of(ReactiveSecurityAutoConfiguration.class, SingleUserAutoConfiguration.class))
            .run(context -> {
                assertThat(context.getBean(ReactiveUserDetailsService.class).findByUsername("michael").block()).isNotNull();
                assertThat(context).getBean(UserDetailsService.class).isNull();
            });
}
项目:configurable-single-user-spring-boot-starter    文件:ReactiveUserDetailsServiceConfigurationTest.java   
@Test
public void configuresNoDefaultUserWhenUserDetailsServicePresent() {
    contextRunner
            .withUserConfiguration(TestConfig.class, UserDetailsRepositoryIsPresent.class)
            .withConfiguration(AutoConfigurations.of(ReactiveSecurityAutoConfiguration.class, SingleUserAutoConfiguration.class))
            .run(context -> {
                assertThat(context.getBean(ReactiveUserDetailsService.class).findByUsername("bob").block()).isNotNull();
                assertThat(context.getBean(ReactiveUserDetailsService.class).findByUsername("michael").block()).isNull();
                assertThat(context).getBean(UserDetailsService.class).isNull();
            });
}
项目:spring-reactive-sample    文件:SecurityConfig.java   
@Bean
public ReactiveUserDetailsService userDetailsService(UserRepository users) {
    return (username) -> users.findByUsername(username).cast(UserDetails.class);
}
项目:configurable-single-user-spring-boot-starter    文件:ReactiveUserDetailsServiceConfiguration.java   
@Bean
public ReactiveUserDetailsService singleUserDetailsService(
        final SingleUserProperties singleUserProperties
) {
    return new MapReactiveUserDetailsService(singleUserProperties.asUser());
}
项目:configurable-single-user-spring-boot-starter    文件:ReactiveUserDetailsServiceConfigurationTest.java   
@Bean
public ReactiveUserDetailsService userDetailsService() {
    return new MapReactiveUserDetailsService(User.withUsername("Bob").password("bobby").roles("USER").build());
}