在使用spring 4.1.6,spring security 4.0.1和JavaConfig的JBOSS EAP 6上运行的Web应用程序中,我们尝试实现LDAP身份验证,而不是在configure中定义LDAP服务器的属性(url等) (AuthenticationManagerBuilder auth)方法我们希望从已经在容器上配置并具有所有必需属性的JBOSS安全域获取属性 .
我们尝试了几件事,并在网上搜索了实现这一目标的方法,但无法找到解决方案 .
这就是我们目前拥有的:
/WEB-INF/jboss-web.xml:jboss-web security-domain java:/ jaas / ad-ldap security-domain jboss-web
安全配置类:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().realmName("ad-ldap");
http.formLogin().loginPage("/login").loginProcessingUrl("/loginProcess");
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userSearchBase("OU=users,DC=local")
.userSearchFilter("(sAMAccountName={0})")
.groupSearchBase("OU=groups,DC=local")
.groupSearchFilter("sAMAccountName={0}");
}
}
谢谢
1 回答
您只需在独立XML中的安全域中定义LDAP服务器URL .
http://www.mastertheboss.com/jboss-server/jboss-security/configure-jboss-with-ldap?start=1但请注意,在上面的示例中,web.xml中的Realm name元素应为:
https://docs.jboss.org/author/display/WFLY8/Examples