org.springframework.security.core.userdetails.ReactiveUserDetailsService Java Examples

The following examples show how to use org.springframework.security.core.userdetails.ReactiveUserDetailsService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GossipApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ReactiveUserDetailsService userDetailsService(AccountDAO accountDAO, Scheduler scheduler) {
    return username -> {
    	return Mono.defer(() -> {
    		return Mono.justOrEmpty(accountDAO.accountByUsername(username))
    		    .map(acct -> {
    		    	return User.withUsername(username)
      		           .password(acct.getPassword())
      		           .roles("MEMBER")
      		           .build();
    		    });
    		    
    	}).subscribeOn(scheduler);
    };
}
 
Example #2
Source File: SecurityReactiveApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ReactiveUserDetailsService userDetailsService(PasswordEncoder passwordEncoder) {
    UserDetails admin = User
	      .withUsername("admin")
	      .password(passwordEncoder.encode("admin12345678"))
	      .roles("ADMIN", "MEMBER")
	      .build();

    UserDetails caterpillar = User
	      .withUsername("caterpillar")
	      .password(passwordEncoder.encode("12345678"))
	      .roles("MEMBER")
	      .build();
    
    return new MapReactiveUserDetailsService(admin, caterpillar);
}
 
Example #3
Source File: CustomReactiveAuthenticationManager.java    From webFluxTemplate with MIT License 5 votes vote down vote up
public CustomReactiveAuthenticationManager(ReactiveUserDetailsService userDetailsService, JwtTokenUtil jwtTokenUtil) {
    Assert.notNull(userDetailsService, "userDetailsService cannot be null");
    Assert.notNull(jwtTokenUtil, "jwtTokenUtil cannot be null");

    this.userDetailsService = userDetailsService;
    this.jwtTokenUtil = jwtTokenUtil;
}
 
Example #4
Source File: JwtAuthenticationConverter.java    From webFluxTemplate with MIT License 5 votes vote down vote up
public JwtAuthenticationConverter(ReactiveUserDetailsService userDetailsService, JwtTokenUtil jwtTokenUtil) {
    Assert.notNull(userDetailsService, "userDetailsService cannot be null");
    Assert.notNull(jwtTokenUtil, "jwtTokenUtil cannot be null");

    this.userDetailsService = userDetailsService;
    this.jwtTokenUtil = jwtTokenUtil;
}
 
Example #5
Source File: ReservationClientApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactiveUserDetailsService authentication() {
		return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
				.username("user")
				.password("password")
				.roles("USER")
				.build()
		);
}
 
Example #6
Source File: ReactiveSecurityApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.roles("USER")
					.username("user")
					.password("password")
					.build());
}
 
Example #7
Source File: ReservationClientApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.username("user")
					.password("password")
					.roles("USER")
					.build()
	);
}
 
Example #8
Source File: ReactiveSecurityApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.roles("USER")
					.username("user")
					.password("password")
					.build());
}
 
Example #9
Source File: GatewayApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ReactiveUserDetailsService userDetailsService(PasswordEncoder passwordEncoder) {
    UserDetails webclient = User
          .withUsername(clientName)
          .password(passwordEncoder.encode(clientSecret))
          .roles("account", "message", "email")
          .build();

    return new MapReactiveUserDetailsService(webclient);
}
 
Example #10
Source File: GossipApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ReactiveUserDetailsService userDetailsService(AccountDAO accountDAO, Scheduler scheduler) {
    return username -> {
    	return Mono.defer(() -> {
    		return Mono.justOrEmpty(accountDAO.accountByUsername(username))
    		    .map(acct -> {
    		    	return User.withUsername(username)
      		           .password(acct.getPassword())
      		           .roles("MEMBER")
      		           .build();
    		    });
    		    
    	}).subscribeOn(scheduler);
    };
}
 
Example #11
Source File: GossipApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
	UserDetailsRepositoryReactiveAuthenticationManager manager = new UserDetailsRepositoryReactiveAuthenticationManager(userDetailsService);
	manager.setPasswordEncoder(passwordEncoder);
	return manager;
}
 
Example #12
Source File: GossipApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
	UserDetailsRepositoryReactiveAuthenticationManager manager = new UserDetailsRepositoryReactiveAuthenticationManager(userDetailsService);
	manager.setPasswordEncoder(passwordEncoder);
	return manager;
}
 
Example #13
Source File: SecurityConfig.java    From spring-reactive-sample with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public ReactiveUserDetailsService userDetailsService(UserRepository users) {
    return (username) -> users.findByUsername(username).cast(UserDetails.class);
}