第 5 章 安全域
安全域将 Data Grid 服务器部署与您的环境中的网络协议和基础架构集成,以控制用户身份并验证用户身份。
5.1. 创建安全域 复制链接链接已复制到粘贴板!
向 Data Grid 服务器配置添加安全域,以控制对部署的访问。您可以在配置中添加一个或多个安全域。
当您向配置添加安全域时,Data Grid 服务器会自动为 Hot Rod 和 REST 端点启用匹配的身份验证机制。
先决条件
- 根据需要,为您的 Data Grid 服务器配置添加套接字绑定。
创建密钥存储或具有 PEM 文件,以使用 TLS/SSL 加密配置安全域。
网格服务器也可以在启动时生成密钥存储。
-
置备安全域配置依赖的资源或服务。
例如,如果您添加令牌域,则需要置备 OAuth 服务。
此流程演示了如何配置多个属性域。开始之前,您需要创建属性文件,以使用命令行界面(CLI)添加用户并分配权限。使用 user create 命令,如下所示:
user create <username> -p <changeme> -g <role> \
--users-file=application-users.properties \
--groups-file=application-groups.properties
user create <username> -p <changeme> -g <role> \
--users-file=management-users.properties \
--groups-file=management-groups.properties
运行 user create --help 获取示例和更多信息。
使用 CLI 向属性域添加凭证只会在您连接的服务器实例上创建用户。您必须在属性域中手动将凭证同步到集群中的每个节点。
流程
- 打开 Data Grid Server 配置以进行编辑。
-
使用安全配置中的
元素,使其包含多个安全域。security-realms 添加一个带有
security-realm元素的安全域,并为它赋予name属性的唯一名称。要遵循示例,请创建一个名为
application-realm的安全域,另一个名为management-realm。-
为 Data Grid 服务器提供 TLS/SSL 识别,并提供
server-identities元素,并根据需要配置密钥存储。 通过添加以下元素或字段来指定安全域的类型:
-
properties-realm -
ldap-realm -
token-realm -
truststore-realm
-
指定您根据需要配置的安全域类型的属性。
要遵循示例,请使用
user-和propertiesgroup-properties元素或字段上的path属性指定您使用 CLI 创建的 dcproperties 文件。-
如果您在配置中添加多种不同类型的安全域,请包含
distributed-realm元素或字段,以便 Data Grid 服务器使用域并相互组合。 -
配置 Data Grid 服务器端点,以使用带有
security-realm属性的安全域。 - 保存对配置的更改。
多个属性域
XML
<server xmlns="urn:infinispan:server:15.0">
<security>
<security-realms>
<security-realm name="application-realm">
<properties-realm groups-attribute="Roles">
<user-properties path="application-users.properties"/>
<group-properties path="application-groups.properties"/>
</properties-realm>
</security-realm>
<security-realm name="management-realm">
<properties-realm groups-attribute="Roles">
<user-properties path="management-users.properties"/>
<group-properties path="management-groups.properties"/>
</properties-realm>
</security-realm>
</security-realms>
</security>
</server>
JSON
{
"server": {
"security": {
"security-realms": [{
"name": "management-realm",
"properties-realm": {
"groups-attribute": "Roles",
"user-properties": {
"digest-realm-name": "management-realm",
"path": "management-users.properties"
},
"group-properties": {
"path": "management-groups.properties"
}
}
}, {
"name": "application-realm",
"properties-realm": {
"groups-attribute": "Roles",
"user-properties": {
"digest-realm-name": "application-realm",
"path": "application-users.properties"
},
"group-properties": {
"path": "application-groups.properties"
}
}
}]
}
}
}
YAML
server:
security:
securityRealms:
- name: "management-realm"
propertiesRealm:
groupsAttribute: "Roles"
userProperties:
digestRealmName: "management-realm"
path: "management-users.properties"
groupProperties:
path: "management-groups.properties"
- name: "application-realm"
propertiesRealm:
groupsAttribute: "Roles"
userProperties:
digestRealmName: "application-realm"
path: "application-users.properties"
groupProperties:
path: "application-groups.properties"