LDAP authentication with JBoss 7

2019-01-26 14:27发布

I want to develop a simple java web application with JBoss 7 server to enable login from username/password entered by the user and authenticate with ldap.

So this is what i wrote in web.xml placed in WEB-INF/

 <login-config>
     <auth-method>BASIC</auth-method>
     <realm-name>Enter user name and password</realm-name>
 </login-config>

then added jboss-web.xml in same folder

 <?xml version="1.0" encoding="UTF-8"?>
 <jboss-web>
     <security-domain>java:/jaas/website-domain</security-domain>  
 </jboss-web>

Then I added the website-domain realm in standalone.xml

<security-domain name="website-domain" cache-type="default">
    <authentication>
        <login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required">
            <module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
            <module-option name="java.naming.provider.url" value="ldap://localhost:10389"/>
            <module-option name="bindDN" value="ou=people,dc=mycompany,dc=com" />
            <module-option name="bindCredential" value="shad"/>
            <module-option name="allowEmptyPasswords" value="false"/>
            <module-option name="Context.REFERRAL" value="follow"/>
            <module-option name="throwValidateError" value="true"/>
            <module-option name="allowEmptyPasswords" value="true"/>
        </login-module>
    </authentication>
</security-domain>

So how the username and password entered will be sent to these modules ? Or do I have to write a custom JAAS realm ? Is their any working example you guys can share me??

标签: jboss ldap
2条回答
家丑人穷心不美
3楼-- · 2019-01-26 15:04

Your webapp needs to point to your security domain website-domain by adding a line in WEB-INF/jboss-web.xml

<security-domain flushOnSessionInvalidation="true">java:/jaas/website-domain</security-domain>

I believe in Jboss 7 you need to only specify website-domain (no java:/jaas/ prefix)

查看更多
登录 后发表回答