我是新来的春天安全。我正在尝试编写自定义身份验证提供程序。它的作品,但我没有找到一个选项,使用密码编码器连同它。
请引导。
我的密码在 https://github.com/payalbnsl/MvcSecurityCustomAuthenticationProvider
它是一个基本的springmvc应用程序,只有一个端点是使用usernamepasswordtoken类型的自定义身份验证提供程序编写的。我想在里面添加密码编码器。有可能吗?
您可以在客户提供程序中创建密码编码器,而不是将编码器插入到您自己的身份验证提供程序中。
CustomAuthenticationProvider 很简单,你可以用 JdbcUserDetailsManager
JdbcUserDetailsManager
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication() .dataSource(datasource) .usersByUsernameQuery("select username,password,1 "+ "from xxx " + "where username = ?") .authoritiesByUsernameQuery("select username, role "+ "from xxx " + "where username = ?") .passwordEncoder(passwordEncoder()) }