首页 > 解决方案 > Jhipster 和 Spring Security - 添加身份验证提供程序保持活动的默认 jdbcauthentication 模式

问题描述

我已经向我的 jHipster 应用程序添加了一个自定义 LDAP 身份验证提供程序机制。没有在类中插入任何configureGlobal(AuthenticationManagerBuilder auth)configureGlobal(AuthenticationManagerBuilder auth)方法SecurityConfiguration,但在我的自定义实现上带有@Component注释AuthenticationProvider,新的身份验证工作正常,但是,我失去了数据库上用户的默认身份验证。

我尝试将其添加到securityConfiguration

@Inject
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    super.configure(auth);
    auth.authenticationProvider(aDauthenticationProvider);
}

但结果是一样的,我失去了数据库身份验证。

如何将默认身份验证机制添加到 AuthenticationManagerBuilder 的提供者列表中?

谢谢

标签: springauthenticationspring-securityldapjhipster

解决方案


我找到了解决方案,如果有人遇到我的问题,我会写这个。

在 GlobalConfigure 方法上添加此代码行就足够了:

auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());

将预定义的 JDBC 身份验证方法添加到身份验证提供程序列表中。


推荐阅读