org.springframework.security.core.userdetails.ReactiveUserDetailsService源码实例Demo

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

下面列出了org.springframework.security.core.userdetails.ReactiveUserDetailsService 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
}
 
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;
}
 
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;
}
 
源代码4 项目: training   文件: ReservationClientApplication.java
@Bean
ReactiveUserDetailsService authentication() {
		return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
				.username("user")
				.password("password")
				.roles("USER")
				.build()
		);
}
 
源代码5 项目: training   文件: ReactiveSecurityApplication.java
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.roles("USER")
					.username("user")
					.password("password")
					.build());
}
 
源代码6 项目: training   文件: ReservationClientApplication.java
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.username("user")
					.password("password")
					.roles("USER")
					.build()
	);
}
 
源代码7 项目: training   文件: ReactiveSecurityApplication.java
@Bean
ReactiveUserDetailsService authentication() {
	return new MapReactiveUserDetailsService(
			User.withDefaultPasswordEncoder()
					.roles("USER")
					.username("user")
					.password("password")
					.build());
}
 
源代码8 项目: Spring5Tutorial   文件: GatewayApplication.java
@Bean
public ReactiveUserDetailsService userDetailsService(PasswordEncoder passwordEncoder) {
    UserDetails webclient = User
          .withUsername(clientName)
          .password(passwordEncoder.encode(clientSecret))
          .roles("account", "message", "email")
          .build();

    return new MapReactiveUserDetailsService(webclient);
}
 
源代码9 项目: Spring5Tutorial   文件: GossipApplication.java
@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);
    };
}
 
源代码10 项目: Spring5Tutorial   文件: GossipApplication.java
@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);
    };
}
 
源代码11 项目: Spring5Tutorial   文件: GossipApplication.java
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
	UserDetailsRepositoryReactiveAuthenticationManager manager = new UserDetailsRepositoryReactiveAuthenticationManager(userDetailsService);
	manager.setPasswordEncoder(passwordEncoder);
	return manager;
}
 
源代码12 项目: Spring5Tutorial   文件: GossipApplication.java
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
	UserDetailsRepositoryReactiveAuthenticationManager manager = new UserDetailsRepositoryReactiveAuthenticationManager(userDetailsService);
	manager.setPasswordEncoder(passwordEncoder);
	return manager;
}
 
源代码13 项目: spring-reactive-sample   文件: SecurityConfig.java
@Bean
public ReactiveUserDetailsService userDetailsService(UserRepository users) {
    return (username) -> users.findByUsername(username).cast(UserDetails.class);
}