3.2. LDAP 域
LDAP 域连接到 LDAP 服务器,如 OpenLDAP、红帽目录服务器、Apache 目录服务器或 Microsoft Active Directory,以验证用户并获取成员资格信息。
LDAP 服务器可以有不同的条目布局,具体取决于服务器和部署的类型。本文档超出了本文档的范围,为所有可能配置提供示例。
端点身份验证机制
当您将 Data Grid Server 配置为使用 LDAP 域时,您可以将端点配置为使用以下身份验证机制:
-
hot Rod (SASL):
PLAIN,DIGEST114, 和SCRAM114 -
REST (HTTP):
Basic和Digest
LDAP 域配置
<security xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:server:12.1 https://infinispan.org/schemas/infinispan-server-12.1.xsd"
xmlns="urn:infinispan:server:12.1">
<security-realms>
<security-realm name="default">
<!-- Names an LDAP realm and specifies connection properties. -->
<ldap-realm name="ldap"
url="ldap://my-ldap-server:10389"
principal="uid=admin,ou=People,dc=infinispan,dc=org"
credential="strongPassword"
connection-timeout="3000"
read-timeout="30000"
connection-pooling="true"
referral-mode="ignore"
page-size="30"
direct-verification="true">
<!-- Defines how principals are mapped to LDAP entries. -->
<identity-mapping rdn-identifier="uid"
search-dn="ou=People,dc=infinispan,dc=org"
search-recursive="false">
<!-- Retrieves all the groups of which the user is a member. -->
<attribute-mapping>
<attribute from="cn"
to="Roles"
filter="(&(objectClass=groupOfNames)(member={1}))"
filter-dn="ou=Roles,dc=infinispan,dc=org"/>
</attribute-mapping>
</identity-mapping>
</ldap-realm>
</security-realm>
</security-realms>
</security>
LDAP 连接的主体必须具有执行 LDAP 查询和访问特定属性所需的权限。
作为使用 direct-verification 属性验证用户凭据的替代方法,您可以使用 user-password-mapper 元素指定 LDAP 密码。
rdn-identifier 属性指定一个 LDAP 属性,它根据提供的标识符查找用户条目,通常是用户名;例如 uid 或 sAMAccountName 属性。在配置中添加 search-recursive="true" 以以递归方式搜索目录。默认情况下,搜索用户条目使用 (rdn_identifier={0}) 过滤器。使用 filter-name 属性指定不同的过滤器。
attribute-mapping 元素检索用户所属的所有组。通常可通过两种方式存储成员资格信息:
-
在组条目下,通常在
member属性中具有 classgroupOfNames。在这种情况下,您可以使用属性过滤器,如上例配置中所示。此过滤器搜索与提供的过滤器匹配的条目,该条目将找到与用户的 DN 相等的成员属性的组。然后,过滤器提取组条目的 CN (由 指定),并将其添加到用户的Roles中。 在
memberOf属性的用户条目中。在这种情况下,您应该使用如下属性引用:<attribute-reference reference="memberOf" from="cn" to="Roles" />此引用从用户条目中获取所有
memberOf属性,提取由 指定的 CN,并将它们添加到用户的Roles中。
3.2.1. LDAP Realm Principal Rewriting 复制链接链接已复制到粘贴板!
有些 SASL 身份验证机制,如 GSSAPI、GS2-KRB5 和 Negotiate,提供需要 清理 的用户名,然后才能使用它来搜索 LDAP 服务器。
<security xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:server:12.1 https://infinispan.org/schemas/infinispan-server-12.1.xsd"
xmlns="urn:infinispan:server:12.1">
<security-realms>
<security-realm name="default">
<ldap-realm name="ldap"
url="ldap://${org.infinispan.test.host.address}:10389"
principal="uid=admin,ou=People,dc=infinispan,dc=org"
credential="strongPassword">
<name-rewriter>
<!-- Defines a rewriter that extracts the username from the principal using a regular expression. -->
<regex-principal-transformer name="domain-remover"
pattern="(.*)@INFINISPAN\.ORG"
replacement="$1"/>
</name-rewriter>
<identity-mapping rdn-identifier="uid"
search-dn="ou=People,dc=infinispan,dc=org">
<attribute-mapping>
<attribute from="cn" to="Roles"
filter="(&(objectClass=groupOfNames)(member={1}))"
filter-dn="ou=Roles,dc=infinispan,dc=org" />
</attribute-mapping>
<user-password-mapper from="userPassword" />
</identity-mapping>
</ldap-realm>
</security-realm>
</security-realms>
</security>