首页 > 编程语言 > 详细

springsecurity

时间:2019-10-25 01:06:52      阅读:109      评论:0      收藏:0      [点我收藏+]

springsecurity旧版本自定义设置用户密码角色

protected void configure(AuthenticationManagerBuilder auth) throws Exception {
 auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN");
 auth.inMemoryAuthentication().withUser("zhangsan").password("zhangsan").roles("ADMIN");
 auth.inMemoryAuthentication().withUser("demo").password("demo").roles("USER");
}

 

2.x新版本(进行了加密):

 auth.inMemoryAuthentication() 

.passwordEncoder(new BCryptPasswordEncoder()).withUser("user1") 

.password(new BCryptPasswordEncoder().encode("123456"))  .roles("USER");

 

springsecurity

原文:https://www.cnblogs.com/share-record/p/11735798.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!