将LDAP组映射到JBoss 5中的角色

时间:2014-06-09 15:30:31

标签: ldap seam jboss5.x

我尝试使用conf/login-config.xml中定义的LDAP提供程序对管理控制台(Admin,JMX,JBoss Web和JBoss WS)的用户进行身份验证:

  <application-policy name="LDAP">
    <authentication>
      <login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required">
        <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>
        <module-option name="java.naming.provider.url">ldaps://ldap.company.com:636</module-option>
        <module-option name="java.naming.security.protocol">ssl</module-option>
        <module-option name="java.naming.security.authentication">simple</module-option>
        <module-option name="bindDN">uid=dummy,cn=users,cn=accounts,dc=company,dc=com</module-option>
        <module-option name="bindCredential">secret</module-option>
        <module-option name="baseCtxDN">cn=accounts,dc=company,dc=com</module-option>
        <module-option name="baseFilter">(&#038;(objectClass=inetOrgPerson)(uid={0}))</module-option>
        <module-option name="rolesCtxDN">cn=groups,cn=accounts,dc=company,dc=com</module-option>
        <module-option name="roleAttributeID">dn</module-option>
        <module-option name="roleFilter">(&#038;(objectClass=posixgroup)(member={1}))</module-option>
        <module-option name="roleRecursion">-1</module-option>
        <module-option name="searchScope">SUBTREE_SCOPE</module-option>
        <module-option name="allowEmptyPasswords">false</module-option>
        <module-option name="searchTimeLimit">-1</module-option>
      </login-module>
      <!-- This login-module is used only in one use case, see below for details
      <login-module code="org.jboss.security.auth.spi.RoleMappingLoginModule" flag="optional">
        <module-option name="rolesProperties">props/admin-console-roles.properties</module-option>
      </login-module>
      -->
    </authentication>
  </application-policy>

已在以下文件中设置了相应的JAAS配置:

$ grep LDAP /usr/share/jbossas/server/node1/deploy/admin-console.war/WEB-INF/*xml
/usr/share/jbossas/server/node1/deploy/admin-console.war/WEB-INF/components.xml:    <security:identity authenticate-method="#{authenticator.authenticate}" jaas-config-name="LDAP"/>
/usr/share/jbossas/server/node1/deploy/admin-console.war/WEB-INF/jboss-web.xml:    <security-domain flushOnSessionInvalidation="true">java:/jaas/LDAP</security-domain>

与LDAP服务器的连接正常工作。我已验证使用wireshark捕获流量并在org.jboss.secutiry中将TRACE设置为jboss-log4j.xml

<category name="org.jboss.security.auth.spi">
  <priority value="TRACE" class="org.jboss.logging.XLevel"></priority>
</category>

我还为DEBUG组件设置了org.jboss.seam级别:

<category name="org.jboss.seam">
  <priority value="DEBUG"/>
</category>

还验证身份验证步骤是否正常运行:

2014-06-09 16:42:41,189 DEBUG [org.jboss.seam.security.Identity] (http-192.0.2.1-8080-6) Login successful for: someuser

授权似乎存在问题,即使用户经过正确身份验证,我也无法访问admin-console。我尝试了两种不同的方法:

  1. 由于我的LDAP中没有名为JBossAdmin的组(默认情况下使用的角色):

    $ grep JBossAdmin -R *
    facelets/resourceNavigation.xhtml:        <h:form id="navTreeForm" rendered="#{s:hasRole('JBossAdmin')}">
    pages.xml:            <rule if="#{s:hasRole('JBossAdmin')}">
    pages.xml:        <restrict>#{s:hasRole('JBossAdmin')}</restrict>
    web.xml:        <role-name>JBossAdmin</role-name>
    

    我尝试使用RoleMappingLoginModule映射我的LDAP组和JBoss角色:

      <login-module code="org.jboss.security.auth.spi.RoleMappingLoginModule" flag="optional">
        <module-option name="rolesProperties">props/admin-console-roles.properties</module-option>
      </login-module>
    

    props/admin-console-roles.properties的内容是:

    someuser=JBossAdmin
    

    如文档所述,语法为username=role1,role2

  2. JBossAdmin的出现次数替换为LDAP结构中存在的一个组,例如developers

    $ grep developers -R *
    facelets/resourceNavigation.xhtml:        <h:form id="navTreeForm" rendered="#{s:hasRole('developers')}">
    pages.xml:            <rule if="#{s:hasRole('developers')}">
    pages.xml:        <restrict>#{s:hasRole('developers')}</restrict>
    web.xml:        <role-name>developers</role-name>
    
  3. 两者都没有奏效。我被困在登录页面上。而且,如果我坚持并再次按下登录按钮,我会对此表示欢迎:

    admin-console

    如何进一步调试?是否可以将LDAP组映射到JBoss 5中的角色?使用role.properties时,可以在RoleMappingLoginModule文件中使用组名(而不是用户名)吗?

0 个答案:

没有答案