【发布时间】:2016-09-23 20:48:25
【问题描述】:
我正在尝试使用自定义登录页面进行 LDAP 身份验证,但它在下面不起作用是我的安全和 ldap 配置
@Configuration
@EnableWebSecurity
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().authorizeRequests().antMatchers("/**").permitAll()
.anyRequest().authenticated()
.and().formLogin().loginPage("/login")
.usernameParameter("username")
.passwordParameter("password")
.failureUrl("/login?error");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource().ldif("classpath:test-server.ldif");
}
}
以下是放置在资源文件夹中的示例 LDif 文件
dn: uid=bob,ou=people,dc=springframework,dc=org 对象类:顶部 对象类:人 对象类:organizationalPerson 对象类:inetOrgPerson cn:鲍勃·汉密尔顿 sn:汉密尔顿 uid:鲍勃 用户密码:bobspassword
我正在寻找只有有效用户才能访问应用程序中的其他页面。
配置有什么问题吗,不胜感激。
【问题讨论】:
标签: java spring spring-security spring-boot ldap