我是 JPA 和 Spring Boot 的新手。
http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt
我正在寻找对密码进行编码 - 我将把这个 bean 放在哪里 - 我只是在我的 application.properties 中还是在 pom.xml 中定义它
最佳答案
您也可以在@Configuration bean中定义,但建议在@@EnableWebSecurity bean中定义密码编码器,它会自动为您添加@Configuration注释,您可以配置更多与安全相关的内容。
@EnableWebSecurity
public class YourWebConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}
}
关于java - JPA - Spring Boot - 密码编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065743/