具有Spring Security和Java Config的自定义身份验证提供程序 [英] Custom Authentication provider with Spring Security and Java Config
本文介绍了具有Spring Security和Java Config的自定义身份验证提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过将Spring Security与Java配置结合使用来定义自定义身份验证提供程序? 我想在自己的数据库上执行登录检查凭据.
How can I define a custom Authentication provider by using Spring Security with Java Configurations? I would like to perform a login checking credentials on my own database.
推荐答案
以下内容满足您的需求(CustomAuthenticationProvider
是您的实现,需要由Spring管理)
The following does what you need (CustomAuthenticationProvider
is your implementation which needs to be managed by Spring)
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomAuthenticationProvider customAuthenticationProvider;
@Override
protected void configure(HttpSecurity http) throws Exception {
/**
* Do your stuff here
*/
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(customAuthenticationProvider);
}
}
这篇关于具有Spring Security和Java Config的自定义身份验证提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文