我目前正在使用Spring Boot创建一个新的Web应用程序,并开始整合Spring Security进行身份验证的过程。在成功地遵循基于Spring Boot的LDAP tutorial之后,我想将基于JavaConfig的配置指向我的Active Directory实例。PartialResultException当使用Spring Security和JavaConfig进行身份验证时
我的应用程序现在可以处理不好凭证预期,但有效凭据现在导致
javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name ''
这是一个常见的问题 - 有些情况下已经遇到此问题的numberofplaces。该解决方案似乎将Context.REFERRAL设置为“跟随”,但我找不到任何文档指出如何使用JavaConfig设置该选项。我唯一的选择是恢复到基于XML的配置吗? Spring似乎在推动开发者朝着JavaConfig方向发展,所以如果可能的话,我想避免混合这两种方法。
以下是我的安全配置:
@Configuration
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/css/**").permitAll().anyRequest()
.fullyAuthenticated().and().formLogin();
}
@Configuration
protected static class AuthenticationConfiguration extends
GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userSearchBase("")
.userSearchFilter("(&(cn={0}))").contextSource()
.managerDn("<username>")
.managerPassword("<password>")
.url("ldap://<url>");
}
}
}