Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class SecurityConfig {
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
public UserDetailsService users(PasswordEncoder encoder) {
UserBuilder users = User.builder().passwordEncoder(encoder::encode);
UserDetails admin = users.username("user").password("password").roles("USER").build();
UserDetails user = users.username("admin").password("password").roles("USER", "ADMIN").build();
return new InMemoryUserDetailsManager(user, admin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment