首页 文章

JBoss Wildfly - 针对LDAP的Web应用程序身份验证

提问于
浏览
3

我在jboss-web.xml中定义了一个安全域,如下所示

<jboss-web>
    <security-domain>java:/jaas/my_ldap_security_domain</security-domain>
    <disable-audit>true</disable-audit>
</jboss-web>

我也在我的standalone.xml中定义了

<subsystem xmlns="urn:jboss:domain:security:1.2">
    <security-domains>
        <security-domain name="my_ldap_security_domain" cache-type="default">
            <authentication>
                <login-module code="LdapExtended" flag="sufficient">
                    <module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
                    <module-option name="java.naming.provider.url" value="ldaps://xxx.xxx.xxx.xxx:yyyy"/>
                    <module-option name="java.naming.security.authentication" value="simple"/>
                    <module-option name="bindDN" value="temp@my.domain"/>
                    <module-option name="bindCredential" value="mypass"/>
                    <module-option name="baseCtxDN" value="DC=my,DC=domain"/>
                    <module-option name="baseFilter" value="(uid={0})"/>
                    <module-option name="rolesCtxDN" value="DC=my,DC=domain"/>
                    <module-option name="roleFilter" value="(uniquemember={1})"/>
                    <module-option name="roleAttributeID" value="cn"/>
                    <module-option name="searchScope" value="SUBTREE_SCOPE"/>
                    <module-option name="roleRecursion" value="0"/>
                    <module-option name="allowEmptyPasswords" value="true"/>
                </login-module>
            </authentication>
        </security-domain>
    </security-domains>
</subsystem>

我在standalone.xml上的唯一领域是

<security-realms>
    <security-realm name="ManagementRealm">
        <authentication>
            <local default-user="$local" skip-group-loading="true"/>
            <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
        </authentication>
        <authorization map-groups-to-roles="false">
            <properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
        </authorization>
    </security-realm>
    <security-realm name="ApplicationRealm">
        <authentication>
            <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
            <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
        </authentication>
        <authorization>
            <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
        </authorization>
    </security-realm>
</security-realms>

之前我没有提到它,因为我认为这个安全领域是为了验证应用程序服务器控制台访问权限 . 对不起 .

我的疑问是如何创建一个jsf2登录页面来验证上面定义的内容 . 我阅读了很多关于但仍然在同一个地方的文章,因为大多数文章使用假身份验证作为示例(与静态字符串比较而不是显示如何咨询LDAP服务器) .

谁能帮我?

1 回答

  • 2

    我假设此安全领域旨在验证应用程序服务器控制台访问权限

    你在那里部分正确 . name="ManagementRealm" 确实指定了用于访问管理功能的领域配置 . name="ApplicationRealm" 将是用于保护Web应用程序的指定属性

    您当前的域配置缺少LDAP身份验证所需的一些内容 . 我认为你已经熟悉web.xml中的登录表单配置了 . 您的领域配置应如下所示,摘录自Wildfly 8 Realm Configuration Manual

    <management>
      <security-realms>
        <security-realm name="ApplicationRealm">
          <authentication>
            <ldap connection="EC2" base-dn="CN=Users,DC=darranl,DC=jboss,DC=org">
              <username-filter attribute="sAMAccountName" />
            </ldap>
          </authentication>
        </security-realm>
     
      </security-realms>
    </management>
    

    <ldap> 标记指定您的查找针对LDAP服务器的位置 . 除此之外,您只需要遵循JavaEE应用程序的标准auth方法 .

    从中可以看出,JavaEE中的Web应用程序安全性通常采用相同的方法

    • 设置领域(特定于应用程序服务器)

    • 在web.xml中设置安全性约束(在所有JavaEE应用程序中统一)

    • 实现登录方法(配置或程序)

    Related

相关问题