部署
官方 Neo4j Kerberos 附加组件可用于扩展 Neo4j 的 Kerberos 认证功能。此附加组件提供认证功能,应与 LDAP 等其他提供商结合使用以进行授权。可从Neo4j 下载站点下载。
Neo4j Kerberos 附加组件 v4.0.0 与所有 Neo4j v4 和 Neo4j v5 版本兼容。 |
我们将在以下部分引导您完成 Kerberos 附加组件的部署。它包含几个步骤:
-
为 Kerberos 配置 Neo4j
-
生成 Kerberos keytab 文件
-
配置 Kerberos 附加组件
有关文件位置,请参阅操作手册 → 文件位置。本文档中的所有相对路径都将根据 neo4j-home 目录解析。
在示例中,我们使用 Windows 上的 Kerberos。我们假设使用 LDAP 进行授权,并且当前领域(Windows 域)为 WINDOMAIN.LOCAL
。
为 Kerberos 配置 Neo4j
将 kerberos-add-on.jar 文件放入 Neo4j 安装的 plugins/ 目录中。编辑 neo4j.conf 以启用 Kerberos 附加组件作为认证提供商。
#For authentication with kerberos-add-on
dbms.security.authentication_providers=plugin-Neo4j-Kerberos
dbms.security.authorization_providers=ldap
#For authorization with LDAP
dbms.security.ldap.host=ad.windomain.local
dbms.security.ldap.authorization.use_system_account=true
dbms.security.ldap.authorization.system_username=CN=neo4jservice,OU=IT-Services,DC=windomain,DC=local
dbms.security.ldap.authorization.system_password=PASSWORD
dbms.security.ldap.authorization.user_search_base=CN=Users,DC=windomain,DC=local
dbms.security.ldap.authorization.user_search_filter=(&(objectClass=*)(SamAccountName={0}))
dbms.security.ldap.authorization.group_membership_attributes=memberOf
dbms.security.ldap.authorization.group_to_role_mapping= \
"CN=Neo4j Read Only,CN=Users,DC=windomain,DC=local" = reader; \
"CN=Neo4j Read-Write,CN=Users,DC=windomain,DC=local" = publisher; \
"CN=Neo4j Schema Manager,CN=Users,DC=windomain,DC=local" = architect; \
"CN=Neo4j Administrator,CN=Users,DC=windomain,DC=local" = admin; \
"CN=Neo4j Procedures,CN=Users,DC=windomain,DC=local" = allowed_role
生成 Kerberos keytab 文件
在 KDC 中为 Neo4j 服务器创建一个服务用户。确保为 Neo4j 服务用户生成一个 keytab 文件,并将其放置在 conf 目录中。在此示例中,我们将其命名为 neo4j.ktab。Neo4j 将使用此 keytab。
配置 Kerberos 附加组件
如果您已经通过 Heimdal 或 MIT 工具 kinit
使用过 Kerberos,您将拥有一个包含如何访问 KDC 信息的 krb5.conf 文件。如果您没有此文件,或者不希望使用它,请在 conf 目录中创建一个新的 krb5.conf 文件。
在此示例中,我们使用的领域为 WINDOMAIN.LOCAL
,KDC 和管理服务器的 IP 地址为 192.168.38.2
。
请将其替换为您实际的领域以及 KDC 和管理服务器的实际 IP 或域名。
[libdefaults]
default_realm = WINDOMAIN.LOCAL
default_tgs_enctypes = rc4-hmac rc4-hmac-exp aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 des3-hmac-sha1
default_tkt_enctypes = rc4-hmac rc4-hmac-exp aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 des3-hmac-sha1
permitted_enctypes = rc4-hmac rc4-hmac-exp aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96 des3-hmac-sha1
[realms]
WINDOMAIN.LOCAL = {
kdc = 192.168.38.2
admin_server = 192.168.38.2
}
[domain_realm]
.windomain.local = WINDOMAIN.LOCAL
windomain.local = WINDOMAIN.LOCAL
某些加密算法不受 Java 原生支持。当使用更高级的加密算法(例如 |
现在,在 conf 目录中创建第二个文件,名为 kerberos.conf。keytab
设置指向上面创建的 keytab 文件。service.principal
设置是该 keytab 中的主体,而 krb5.conf
设置指向 krb5.conf 文件(该文件可能已存在于现有 Kerberos 安装中,或在上一步中创建)。
同样,请根据您的设置替换为正确的值。
realm=WINDOMAIN.LOCAL
keytab=conf/neo4j.ktab
service.principal=neo4j/neo4j.windomain.local@WINDOMAIN.LOCAL
krb5.conf=conf/krb5.conf