MongoDB Enterpriseは以下をサポートします。
LDAP(Lightweight Directory Access Protocol)サービスへの認証リクエストをプロキシする。
LDAP サーバーへの簡易バインディングと SASL バインディング。 MongoDB Enterprise は、
saslauthdまたはオペレーティング システム ライブラリを介して LDAP サーバーにバインドできます。
詳細については、MongoDB Server ドキュメントの 「 LDAP プロキシ認証 」および 「 LDAP 認証 」セクションを参照してください。
Kubernetes Operator を使用して、MongoDB 配置に接続するクライアント アプリケーションを認証するための LDAP を構成できます。 このガイドでは、クライアント アプリケーションから MongoDB 配置への LDAP 認証を構成する方法について説明します。
注意
Kubernetes クラスターでは MongoDB のスタンドアロン インスタンスを保護することはできません。
Considerations
CustomResourceDefinitions で LDAP を構成するには、 Kubernetes Operator MongoDBリソース仕様の
spec.security.authentication.ldapおよびMongoDB Agent に固有のその他のセキュリティ LDAP 設定の下のパラメーターを使用します。このセクションの手順では、必要な設定について説明し、LDAP 構成の例を示します。セキュリティを強化するには、 TLS で暗号化されたレプリカセットまたはTLS で暗号化されたシャーディングされたクラスターを配置することを検討してください。 TLS による暗号化は任意です。 デフォルトでは、 LDAPトラフィックはプレーン テキストとして送信されます。 つまり、ユーザー名とパスワードがネットワークの攻撃に公開されます。 Microsoft Active Directory などの多くの最新のディレクトリ サービスでは、暗号化された接続が必要です。 Kubernetes Operator MongoDB 配置で認証リクエストを暗号化するために、 TLS / SSL 経由で LDAP を使用することを検討してください。
一般的な前提条件
MongoDB 配置の LDAP 認証を構成する前に、次のタスクを完了してください。
MongoDB Enterprise データベース リソースを配置することを確認します。 MongoDB Community データベースは LDAP 認証をサポートしていません。
レプリカセット を配置するか、 LDAP で保護するクライアント認証を持つシャーディングされ たクラスター を配置します。
レプリカセットの LDAP クライアント認証の構成
サンプルレプリカセットリソースをコピーします。
このYAMLファイルの設定を、必要なレプリカセット構成に合わせて変更します。
1 2 apiVersion: mongodb.com/v1 3 kind: MongoDB 4 metadata: 5 name: <my-replica-set> 6 spec: 7 members: 3 8 version: "8.0.0" 9 opsManager: 10 configMapRef: 11 # Must match metadata.name in ConfigMap file 12 name: <configMap.metadata.name> 13 credentials: <mycredentials> 14 type: ReplicaSet 15 persistent: true
16 security: 17 tls: 18 ca: <custom-ca> 19 certsSecretPrefix: <prefix> 20 ...
レプリカセットリソースの LDAP 設定を構成します。
配置でLDAPを有効にするには、Kubernetes オブジェクトで次の設定を構成します。
キー | の種類と必要性 | 説明 | 例 |
|---|---|---|---|
spec.security | boolean, required | LDAP 認証を有効にするには、 を |
|
spec.security | string, required | LDAP サーバーに接続するときに MongoDB がバインドする LDAP 識別名を指定します。 |
|
spec.security | string, required |
| |
spec.security | string, optional | 配置の TLS 証明書に署名するために使用したカスタム CA を保存する ConfigMap の名前を追加します。 |
|
spec.security | string, optional | LDAP サーバーの TLS 証明書を検証する CA を保存するフィールド名を追加します。 |
|
spec.security | array of strings, required | 1 つ以上の LDAP サーバーの |
|
spec.security | string, optional | LDAPS( TLS経由の LDAP )を使用するには、 を |
|
spec.security | string, required | 認証用に指定されたユーザー名を 詳しくは、 security.ldap.userToDNMappingを参照してください。 MongoDB Server ドキュメントの「 およびLDAP クエリ テンプレート」。 |
|
spec.security | string, required | 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 database 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 MongoDB リソース仕様 のセキュリティ設定を参照してください。 また、LDAP 対応の Kubernetes Operator ユーザー配置で MongoDB Agent ユーザーのspec.security.authentication.agents.automationUserName設定も参照してください。
MongoDB Agent の LDAP 設定を構成します。
Kubernetes Operator MongoDB リソース仕様 から、エージェントに固有の セキュリティ設定 を使用し て MongoDB リソースを更新します 。結果の構成は、次の例のようになります。
security: authentication: agents: automationPasswordSecretRef: key: automationConfigPassword name: automation-config-password automationUserName: mms-automation-agent clientCertificateSecretRef: name: agent-client-cert mode: LDAP enabled: true ldap: bindQueryPasswordSecretRef: name: bind-query-password bindQueryUser: cn=admin,dc=example,dc=org servers: - openldap.namespace.svc.cluster.local:389 userToDNMapping: '[{match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org"}]' modes: - LDAP - SCRAM requireClientTLSAuthentication: false
レプリカセットの配置に変更を適用します。
レプリカセットを更新するには、次の Kubernetes コマンドを呼び出します。
kubectl apply -f <replica-set-conf>.yaml
配置のステータスを追跡します。
MongoDBリソースのステータスを確認するには、次のコマンドを使用します。
kubectl get mdb <resource-name> -o yaml -w
-w (監視)フラグが設定されている場合、構成が変更されると、ステータスフェーズがRunning状態に達するまで出力が直ちに更新されます。 リソース配置ステータスの詳細については、 「 Kubernetes 演算子のトラブルシューティング 」を参照してください。
シャーディングされたクラスターの LDAP クライアント認証の構成
サンプルシャーディングされたクラスターリソース をコピーします。
このYAMLファイルの設定を、シャーディングされたクラスターの構成に合わせて変更します。
1 2 apiVersion: mongodb.com/v1 3 kind: MongoDB 4 metadata: 5 name: <my-sharded-cluster> 6 spec: 7 shardCount: 2 8 mongodsPerShardCount: 3 9 mongosCount: 2 10 configServerCount: 3 11 version: "8.0.0" 12 opsManager: 13 configMapRef: 14 name: <configMap.metadata.name> 15 # Must match metadata.name in ConfigMap file 16 credentials: <mycredentials> 17 type: ShardedCluster 18 persistent: true
19 security: 20 tls: 21 ca: <custom-ca> 22 certsSecretPrefix: <prefix> 23 ...
シャーディングされたシャーディングされたクラスターリソースの LDAP 設定を構成します。
配置でLDAPを有効にするには、Kubernetes オブジェクトで次の設定を構成します。
キー | の種類と必要性 | 説明 | 例 |
|---|---|---|---|
spec.security | boolean, required | LDAP 認証を有効にするには、 を |
|
spec.security | string, required | LDAP サーバーに接続するときに MongoDB がバインドする LDAP 識別名を指定します。 |
|
spec.security | string, required |
| |
spec.security | string, optional | 配置の TLS 証明書に署名するために使用したカスタム CA を保存する ConfigMap の名前を追加します。 |
|
spec.security | string, optional | LDAP サーバーの TLS 証明書を検証する CA を保存するフィールド名を追加します。 |
|
spec.security | array of strings, required | 1 つ以上の LDAP サーバーの |
|
spec.security | string, optional | LDAPS( TLS経由の LDAP )を使用するには、 を |
|
spec.security | string, required | 認証用に指定されたユーザー名を 詳しくは、 security.ldap.userToDNMappingを参照してください。 MongoDB Server ドキュメントの「 およびLDAP クエリ テンプレート」。 |
|
spec.security | string, required | 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 database 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 MongoDB リソース仕様 のセキュリティ設定を参照してください。 また、LDAP 対応の Kubernetes Operator ユーザー配置で MongoDB Agent ユーザーのspec.security.authentication.agents.automationUserName設定も参照してください。
MongoDB Agent の LDAP 設定を構成します。
Kubernetes Operator MongoDB リソース仕様 から、エージェントに固有の セキュリティ設定 を使用し て MongoDB リソースを更新します 。結果の構成は、次の例のようになります。
security: authentication: agents: automationPasswordSecretRef: key: automationConfigPassword name: automation-config-password automationUserName: mms-automation-agent clientCertificateSecretRef: name: agent-client-cert mode: LDAP enabled: true ldap: bindQueryPasswordSecretRef: name: bind-query-password bindQueryUser: cn=admin,dc=example,dc=org servers: - openldap.namespace.svc.cluster.local:389 userToDNMapping: '[{match: "(.+)",substitution: "uid={0},ou=groups,dc=example,dc=org"}]' modes: - LDAP - SCRAM requireClientTLSAuthentication: false
変更をシャーディングされたクラスターの配置に適用します。
次の Kubernetes コマンドを呼び出して、シャーディングされたクラスターを更新します。
kubectl apply -f <sharded-cluster-conf>.yaml
配置のステータスを追跡します。
MongoDBリソースのステータスを確認するには、次のコマンドを使用します。
kubectl get mdb <resource-name> -o yaml -w
-w (監視)フラグが設定されている場合、構成が変更されると、ステータスフェーズがRunning状態に達するまで出力が直ちに更新されます。 リソース配置ステータスの詳細については、 「 Kubernetes 演算子のトラブルシューティング 」を参照してください。