我能够使用spring data ldap模块创建用户,当我尝试使用userid和password进行身份验证时,它给出了错误。我的猜测是,当创建用户时,ladp正在对密码执行一些加密,并将其保存到ldap树中。我怎么知道ldao使用的是哪种加密。我已经看过一些如何使用spring-security-ldap对用户进行身份验证的示例,我需要使用spring-data-ldap的帮助。任何想法都将受到感谢。
谢谢
发布于 2019-07-10 20:11:50
下面是我在工作中获得代码,这些代码使用LDAP作为身份验证提供者来提供spring安全性的配置。也许它会给你一些关于如何让它工作的洞察。我添加了一些注释来描述实现的一些关键点。这是我的扩展WebSecurityConfigurerAdapter的配置类中的代码。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login") // defines the login page
.loginProcessingUrl("/userAuth") // defines the endpoint which the post with the login form must be sent to.
.permitAll()
.and()
.logout()
.permitAll()
}
@Override
public void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider()); // defines LDAP as your authentication provider.
}
@Bean
public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider authenticationProvider = new ActiveDirectoryLdapAuthenticationProvider(DOMAIN, URL, ROOT_DN); // instantiate and connects to your LDAP provider. DOMAIN, URL and ROOT_DN must be info you have from your LDAP.
authenticationProvider.setConvertSubErrorCodesToExceptions(true);
authenticationProvider.setUseAuthenticationRequestCredentials(true);
return authenticationProvider;
}有了这样的实现,来自/login并发布到/userAuth的任何登录表单都将在您的LDAP服务器上进行身份验证。因此,您不应该担心密码加密或其他任何问题。LDAP身份验证提供程序为您提供了支持。
https://stackoverflow.com/questions/56956734
复制相似问题