springsecurity舊版本自定義設置用戶密碼角色 protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("ad ...
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");