对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

配置多集群LDAP身份验证

MongoDB Enterprise支持:

  • 将身份验证请求代理到轻量级目录访问协议 (LDAP) 服务。

  • 与 LDAP 服务器的简单 SASL 绑定。 MongoDB Enterprise 可以通过saslauthd或操作系统库绑定到 LDAP 服务器。

要了解更多信息,请参阅 MongoDB Server 文档中的LDAP 代理身份验证LDAP 授权部分。

您可以使用 Kubernetes Operator 配置LDAP ,以对连接到多 Kubernetes 集群 MongoDB 部署的客户端应用程序进行身份验证。 本指南介绍如何配置从客户端应用程序到多 Kubernetes 集群 MongoDB 部署的LDAP身份验证。

  • To configure LDAP in CustomResourceDefinitions, use the parameters under the spec.security.authentication.ldap and other security LDAP settings specific to the MongoDB Agent, from the Kubernetes Operator MongoDB resource specification. The procedures in this section describe the required settings and provide examples of LDAP configuration.

  • To improve security, consider deploying a TLS-encrypted multi-cluster. Encryption with TLS is optional. By default, LDAP traffic is sent as plain text. This means that username and password are exposed to network threats. Many modern directory services, such as Microsoft Active Directory, require encrypted connections. Consider using LDAP over TLS to encrypt authentication requests in your Kubernetes Operator MongoDB deployments.

在使用TLS加密保护多 Kubernetes集群MongoDB 部署之前,请完成以下任务:

1

使用 Kubernetes 操作符 MongoDBMultiCluster 资源规范中 的安全设置 更新 MongoDBMultiCluster 自定义资源 。

要在部署中启用LDAP ,请在 Kubernetes 对象中配置以下设置:

类型和必要性
说明
例子

布尔值,
必需

设置为true可启用 LDAP 身份验证。

true

string,
必需

指定连接到 LDAP 服务器时 MongoDB 绑定到的 LDAP 标识名。

cn=admin,dc=example,dc=org

string,
必需

指定包含LDAP绑定标识名密码的密钥名称, MongoDB在连接到LDAP服务器时使用该密码进行绑定。

<secret-name>

string、
可选

添加 ConfigMap 的名称,该名称存储用于签署您部署的 TLS 证书的自定义 CA

<configmap-name>

string、
可选

添加用于存储验证 LDAP 服务器的 TLS 证书的 CA 的字段名称。

<configmap-key>

字符串数组,
必需

指定一个或多个 LDAP 服务器的hostname:port组合列表。 对于每个服务器,使用单独的一行。

<example.com:636>

string、
可选

设置为tls可使用 LDAPS (LDAP over TLS )。 如果 LDAP 服务器不接受 TLS,请留空。 在部署数据库资源时,必须启用 TLS 才能使用此设置。

tls

string,
必需

Specify the mapping that maps the username provided to mongod or mongos for authentication to an LDAP Distinguished Name (DN).

要了解更多信息,请参阅security.ldap.userToDNMappingLDAP LDAP MongoDB Server文档中的 查询模板 。

<match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org">

string,
必需

设置为LDAP可通过 LDAP 启用身份验证。

LDAP

生成的配置可能类似于以下示例:

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 操作符 MongoDBMultiCluster 资源规范中的安全设置。另请参阅启用 LDAP 的 Kubernetes 操作符部署中 MongoDB Agent 用户的spec.security.authentication.agents.automationUserName设置。

2
  1. 对于成员集群,运行以下命令验证 MongoDB Pod 是否处于运行状态:

    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
  2. 在操作符集群中,运行以下命令以验证 MongoDBMultiCluster资源是否处于运行状态:

    kubectl --context=$MDB_CENTRAL_CLUSTER_FULL_NAME \
    --namespace mongodb \
    get mdbmc multi-replica-set -o yaml -w