0

我想通过 ldap 使用身份验证领域。这工作正常。其次,我想将我的应用程序的 UserRoles 存储在 Roles 表中,这也很好。(下面的示例,带有聚合领域)

但我不知道如何获得这两个角色。来自 LDAP 和我的 Roles 表的角色放在一起。

我错过了什么?

         <security-domain name="securtiyDomain" default-realm="my-realm" permission-mapper="default-permission-mapper">
                <realm name=jdbc-realm"   role-decoder="from-roles-attribute"/>
            </security-domain>
   
        <security-realms>
            <aggregate-realm name="my-realm" authentication-realm="ldap-realm" authorization-realms="jdbc-realm ldap-realm"/>

            <jdbc-realm name="jdbc-realm">
                <principal-query .... >
                    <attribute-mapping>
                        <attribute to="roles" index="1"/>
                    </attribute-mapping>
                </principal-query>
            </jdbc-realm>

            <ldap-realm name="ldap-realm" dir-context="ldap-connection" direct-verification="true">
                <identity-mapping ...>
                    <attribute-mapping>
                        <attribute from="cn" to="Roles" .../>
                    </attribute-mapping>
                    <user-password-mapper from="userPassword"/>
                </identity-mapping>
            </ldap-realm>

            <simple-role-decoder name="from-roles-attribute" attribute="roles"/>
4

1 回答 1

0

您的安全域配置在其领域列表中没有聚合my-realm领域。试试下面的方法:

<security-domain name="securtiyDomain" default-realm="my-realm" permission-mapper="default-permission-mapper">
    <realm name=my-realm"   role-decoder="from-roles-attribute"/>
</security-domain>
于 2022-01-13T23:12:39.123 回答