美文网首页
InMemoryUserDetailsManager

InMemoryUserDetailsManager

作者: hemiao3000 | 来源:发表于2022-05-25 12:10 被阅读0次

InMemoryUserDetailsManager 是 Spring Security 内置的 UserDetailsService 的实现类之一。<small>如果,你想验证、学习 Spring Security 的其他特性( 知识点 )而懒得去自定义一个 UserDetailsService 的实现类时,你可以利用它。</small>

启用 InMemoryUserDetailsManager 很简单,只需要在 configure 方法中进行配置即可:

@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
        .withUser("tommy").password(passwordEncoder().encode("123")).roles("admin")
        .and()
        .withUser("jerry").password(passwordEncoder().encode("123")).roles("user");
}

相关文章

网友评论

      本文标题:InMemoryUserDetailsManager

      本文链接:https://www.haomeiwen.com/subject/gtueprtx.html