5.2. 设置 Kerberos 身份
在 Data Grid Server 配置中的安全域中添加 Kerberos 身份,以使用包含服务主体名称和加密密钥(派生自 Kerberos 密码)的 keytab 文件。
先决条件
- 具有 Kerberos 服务帐户主体。
注意
keytab 文件可以包含用户和服务帐户主体。但是,Data Grid 服务器只使用服务帐户主体,这意味着它可以向客户端提供身份并允许客户端与 Kerberos 服务器进行身份验证。
在大多数情况下,您可以为 Hot Rod 和 REST 端点创建唯一的主体。例如,如果您在 "INFINISPAN.ORG" 域中有"datagrid"服务器,则应创建以下服务主体:
-
HotRod/datagrid@INFINISPAN.ORG标识 Hot Rod 服务。 -
HTTP/datagrid@INFINISPAN.ORG标识 REST 服务。
流程
为 Hot Rod 和 REST 服务创建 keytab 文件。
- Linux
ktutil ktutil: addent -password -p datagrid@INFINISPAN.ORG -k 1 -e aes256-cts Password for datagrid@INFINISPAN.ORG: [enter your password] ktutil: wkt http.keytab ktutil: quit- Microsoft Windows
ktpass -princ HTTP/datagrid@INFINISPAN.ORG -pass * -mapuser INFINISPAN\USER_NAME ktab -k http.keytab -a HTTP/datagrid@INFINISPAN.ORG
-
将 keytab 文件复制到 Data Grid Server 安装的
server/conf目录中。 - 打开 Data Grid Server 配置进行编辑。
-
在 Data
Grid 服务器安全域中添加服务器事件定义。 - 指定向 Hot Rod 和 REST 连接器提供服务主体的 keytab 文件的位置。
- 将 Kerberos 服务主体命名为 Kerberos。
- 保存对您的配置的更改。
Kerberos 身份配置
XML
<server xmlns="urn:infinispan:server:14.0">
<security>
<security-realms>
<security-realm name="kerberos-realm">
<server-identities>
<!-- Specifies a keytab file that provides a Kerberos identity. -->
<!-- Names the Kerberos service principal for the Hot Rod endpoint. -->
<!-- The required="true" attribute specifies that the keytab file must be present when the server starts. -->
<kerberos keytab-path="hotrod.keytab"
principal="hotrod/datagrid@INFINISPAN.ORG"
required="true"/>
<!-- Specifies a keytab file and names the Kerberos service principal for the REST endpoint. -->
<kerberos keytab-path="http.keytab"
principal="HTTP/localhost@INFINISPAN.ORG"
required="true"/>
</server-identities>
</security-realm>
</security-realms>
</security>
<endpoints>
<endpoint socket-binding="default"
security-realm="kerberos-realm">
<hotrod-connector>
<authentication>
<sasl server-name="datagrid"
server-principal="hotrod/datagrid@INFINISPAN.ORG"/>
</authentication>
</hotrod-connector>
<rest-connector>
<authentication server-principal="HTTP/localhost@INFINISPAN.ORG"/>
</rest-connector>
</endpoint>
</endpoints>
</server>
JSON
{
"server": {
"security": {
"security-realms": [{
"name": "kerberos-realm",
"server-identities": [{
"kerberos": {
"principal": "hotrod/datagrid@INFINISPAN.ORG",
"keytab-path": "hotrod.keytab",
"required": true
},
"kerberos": {
"principal": "HTTP/localhost@INFINISPAN.ORG",
"keytab-path": "http.keytab",
"required": true
}
}]
}]
},
"endpoints": {
"endpoint": {
"socket-binding": "default",
"security-realm": "kerberos-realm",
"hotrod-connector": {
"authentication": {
"security-realm": "kerberos-realm",
"sasl": {
"server-name": "datagrid",
"server-principal": "hotrod/datagrid@INFINISPAN.ORG"
}
}
},
"rest-connector": {
"authentication": {
"server-principal": "HTTP/localhost@INFINISPAN.ORG"
}
}
}
}
}
}
YAML
server:
security:
securityRealms:
- name: "kerberos-realm"
serverIdentities:
- kerberos:
principal: "hotrod/datagrid@INFINISPAN.ORG"
keytabPath: "hotrod.keytab"
required: "true"
- kerberos:
principal: "HTTP/localhost@INFINISPAN.ORG"
keytabPath: "http.keytab"
required: "true"
endpoints:
endpoint:
socketBinding: "default"
securityRealm: "kerberos-realm"
hotrodConnector:
authentication:
sasl:
serverName: "datagrid"
serverPrincipal: "hotrod/datagrid@INFINISPAN.ORG"
restConnector:
authentication:
securityRealm: "kerberos-realm"
serverPrincipal" : "HTTP/localhost@INFINISPAN.ORG"