使用 Spring Security 和 Java Config 的自定义身份验证提供程序

2024-02-13

如何使用 Spring Security 和 Java 配置来定义自定义身份验证提供程序? 我想在我自己的数据库上执行登录检查凭据。


以下内容满足您的需要(CustomAuthenticationProvider是您的实现,需要由 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);
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Spring Security 和 Java Config 的自定义身份验证提供程序 的相关文章

随机推荐