使用 LDAP 安全客户端身份验证
在本页
MongoDB 企业版 支持
将身份验证请求代理到轻量级目录访问协议(LDAP)服务。
简单的 SASL 绑定到 LDAP 服务器。MongoDB 企业版可以通过
saslauthd
或操作系统库与 LDAP 服务器绑定。
要了解更多信息,请参阅 MongoDB 服务器文档中的 LDAP 代理身份验证 和 LDAP 授权 部分。
您可以使用Kubernetes Operator来配置 LDAP 以身份验证连接到您的多Kubernetes集群MongoDB部署。本指南描述了如何从客户端应用程序配置LDAP身份验证到您的多Kubernetes集群MongoDB部署.
注意事项
要在CustomResourceDefinitions中配置LDAP,请使用以下参数:
spec.security.authentication.ldap
以及其他针对MongoDB Agent的特定安全LDAP设置,从Kubernetes OperatorMongoDB资源规范。本节中的过程描述了所需设置并提供了LDAP配置的示例。为了提高安全性,考虑部署一个TLS加密的多集群。使用TLS进行加密是可选的。默认情况下,LDAP流量以纯文本形式发送。这意味着用户名和密码会暴露给网络威胁。许多现代目录服务,如Microsoft Active Directory,需要加密连接。考虑在您的MongoDB部署中使用LDAP通过TLS/SSL来加密身份验证请求。Kubernetes Operator。
先决条件
在您使用TLS加密确保多Kubernetes集群MongoDB部署之前完成以下任务
按照快速入门先决条件中的步骤。
使用多Kubernetes集群快速入门部署多集群。
为多Kubernetes集群副本集配置LDAP客户端身份验证
更新您的MongoDBMultiCluster
资源以启用LDAP身份验证。
使用MongoDBMultiCluster资源规范中的安全设置更新您的MongoDBMultiCluster自定义资源Kubernetes Operator 以启用您的部署中的LDAP.
要启用您的部署中的LDAP,在您的Kubernetes对象中配置以下设置
键 | 类型和必要性 | 描述 | 示例 |
---|---|---|---|
spec.security | 布尔值, 必需 | 将设置 |
|
spec.security | 字符串, 必需 | 指定MongoDB连接LDAP服务器时绑定的LDAP区分名称。 |
|
spec.security | 字符串, 必需 | 指定包含LDAP绑定唯一名称密码的secret名称,该密码是MongoDB连接到LDAP服务器时使用的。 |
|
spec.security | 字符串, 可选 | 添加包含您用于签署部署TLS证书的自定义CA的ConfigMap的名称。 |
|
spec.security | 字符串, 可选 | 添加存储验证LDAP服务器TLS证书的CA的字段名称。 |
|
spec.security | 字符串数组, 必需 | 指定一个或多个LDAP服务器的 |
|
spec.security | 字符串, 可选 | 设置为 |
|
spec.security | 字符串, 必需 |
| |
spec.security | 字符串, 必需 | 设置为 |
|
生成的配置可能看起来与以下示例类似
security: authentication: enabled: true # Enabled LDAP Authentication Mode modes: - "LDAP" - "SCRAM" # LDAP related configuration ldap: # Specify the hostname:port combination of one or # more LDAP servers servers: - "ldap1.example.com:636" - "ldap2.example.com:636" # Set to "tls" to use LDAP over TLS. Leave blank if # the LDAP server doesn't accept TLS. You must enable TLS when # you deploy the multi-cluster resource to use this setting. transportSecurity: "tls" # If TLS is enabled, add a reference to a ConfigMap that # contains a CA certificate that validates the LDAP server's # TLS certificate. caConfigMapRef: name: "<configmap-name>" key: "<configmap-entry-key>" # Specify the LDAP Distinguished Name to which # MongoDB binds when connecting to the LDAP server bindQueryUser: "cn=admin,dc=example,dc=org" # Specify the password with which MongoDB binds # when connecting to an LDAP server. This is a # reference to a Secret Kubernetes Object containing # one "password" key. bindQueryPasswordSecretRef: name: "<secret-name>"
有关 LDAP 设置的完整列表,请参阅文档中的安全设置Kubernetes Operator
MongoDBMultiCluster 资源规范。也请参阅在您的启用了 LDAP 的 spec.security.authentication.agents.automationUserName
设置中的 MongoDB Agent 用户Kubernetes Operator部署。
验证 MongoDBMultiCluster
资源正在运行。
对于成员集群,运行以下命令以验证 MongoDB Pods 是否处于运行状态
kubectl get pods \ --context=$MDB_CLUSTER_1_FULL_NAME \ --namespace mongodb kubectl get pods \ --context=$MDB_CLUSTER_2_FULL_NAME \ --namespace mongodb kubectl get pods \ --context=$MDB_CLUSTER_3_FULL_NAME \ --namespace mongodb 在中央集群中,运行以下命令以验证
MongoDBMultiCluster
资源是否处于运行状态kubectl --context=$MDB_CENTRAL_CLUSTER_FULL_NAME \ --namespace mongodb \ get mdbmc multi-replica-set -o yaml -w