Search in sources :

Example 1 with MapReactiveUserDetailsService

use of org.springframework.security.core.userdetails.MapReactiveUserDetailsService in project tutorials by eugenp.

the class SecurityConfig method userDetailsService.

@Bean
public MapReactiveUserDetailsService userDetailsService() {
    UserDetails user = User.withDefaultPasswordEncoder().username("user").password("password").roles("USER").build();
    UserDetails admin = User.withDefaultPasswordEncoder().username("admin").password("password").roles("ADMIN").build();
    return new MapReactiveUserDetailsService(user, admin);
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) MapReactiveUserDetailsService(org.springframework.security.core.userdetails.MapReactiveUserDetailsService) Bean(org.springframework.context.annotation.Bean)

Example 2 with MapReactiveUserDetailsService

use of org.springframework.security.core.userdetails.MapReactiveUserDetailsService in project spring-boot by spring-projects.

the class ReactiveUserDetailsServiceAutoConfiguration method reactiveUserDetailsService.

@Bean
public MapReactiveUserDetailsService reactiveUserDetailsService(SecurityProperties properties, ObjectProvider<PasswordEncoder> passwordEncoder) {
    SecurityProperties.User user = properties.getUser();
    UserDetails userDetails = getUserDetails(user, getOrDeducePassword(user, passwordEncoder.getIfAvailable()));
    return new MapReactiveUserDetailsService(userDetails);
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) SecurityProperties(org.springframework.boot.autoconfigure.security.SecurityProperties) MapReactiveUserDetailsService(org.springframework.security.core.userdetails.MapReactiveUserDetailsService) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)2 MapReactiveUserDetailsService (org.springframework.security.core.userdetails.MapReactiveUserDetailsService)2 UserDetails (org.springframework.security.core.userdetails.UserDetails)2 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 SecurityProperties (org.springframework.boot.autoconfigure.security.SecurityProperties)1