0
我想要一個用戶能夠通過他的用戶名和郵件登錄嗎?如何使用我的spring安全配置來實現這一點?如何根據郵件和uid使用spring Security從LDAP驗證用戶?
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin().passwordParameter("password");
}
@Configuration
protected static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
@Autowired
LdapContextSource contextSource;
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0}")
.contextSource(contextSource);
}
}
}
在userDnPatterns可以指定另一個屬性與uid?或使用uid進行身份驗證是標準的?