我目前正在使用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>");
}
}
}