Cloud Foundry Enterprise Environment のための LDAP 認証の構成

Cloud Foundry Enterprise Environment でユーザー認証に LDAP 認証を使用することができます。

Cloud Foundry Enterprise Environment のインストール (『Installing Cloud Foundry Enterprise Environment のインストール』を参照) の前または後の任意の時点で、以下の説明に従って LDAP 認証を構成できます。 この構成は、組み込みの拡張機能である cfp-ext-ldap をメインの Cloud Foundry Enterprise Environment デプロイメントに追加することによって行います。 Cloud Foundry Enterprise Environment での拡張機能の使用を参照してください。 cfp-ext-ldap 拡張機能は、ユーザー・アカウントおよび認証 (UAA) サーバーのデプロイメント・プロパティーを変更します。

LDAP 認証を構成する前に、LDAP または Active Directory ドメインにユーザーを作成する必要があります。 グループを使用して、Cloud Foundry Enterprise Environment 環境へのアクセスをフィルターに掛けることができます。

構成の準備

LDAP 構成は、以下の手順で <ldap_config_file> と称されている、YAML 形式のファイルに保管されます。 このファイルを作成して (例: ldapconfig.yml)、サンプル構成に示すように uiconfig: セクションに構成詳細を配置します。

Cloud Foundry deployment tool を使用する場合は、cfp-ext-ldap 拡張機能によって構成値のガイド付き編集が提供されます。 「状態」ページで「拡張機能の追加」をクリックし、cfp-ext-ldap を選択してから、ダイアログを完了します。 「構成」ページに移動し、拡張機能のリストで cfp-ext-ldap を見つけます。 構成タイプ Simple BindingSearch and BindGroups Map to Scopes、または Groups as Scopes を選択してください。 Cloud Foundry deployment tool で、選択したシナリオの必須およびオプションの構成値が表示されます。 Cloud Foundry deployment tool で、構成値の説明、サンプル値、および検証が提供されます。 拡張機能について詳しくは、『拡張機能の使用』を参照してください。

LDAP 認証を構成するには、以下の選択を行う必要があります。

注: 初期デプロイメント後に Cloud Foundry Enterprise Environment 用の LDAP を追加する場合は、「インストーラー・アクション」に「アップグレード」を選択する必要があります。

サンプル構成

uiconfig:
  enabled: true 
  url: 'ldap://ldap.local.bluemix.net'  # LDAP server URL (space-separated list permitted)
  add_shadow_user_on_login: true        # Enable to allow any LDAP user to log in; otherwise, accounts
                                        #   must be created manually (default value is true)

# BEGIN Include and customize the following lines to use simple-binding
            profile_type: simple-bind
            userDNPattern: 'cn={0},dc=local,dc=bluemix,dc=net;cn={0},dc=example,dc=org'
# END

# BEGIN Include and customize the following lines to use search-and-bind
            profile_type: search-and-bind
            userDN: 'cn=admin,dc=local,dc=bluemix,dc=net'
            userPassword: '**********'
  searchBase: 'dc=local,dc=bluemix,dc=net'  # Specify if only part of the directory should be searched
  searchFilter: 'cn={0}'                    # User name is inserted into this filter in place of {0}
# END

# BEGIN Include the following lines to customize which LDAP attributes are used to populate the UAA user record
  mailAttributeName: emailAddress       # Attribute containing email address of user (default is 'mail')
  mailSubstitute: 'generated-{0}@ldap'  # Form for generated email address if none found in LDAP record
                                        #   (default is {0}@user.from.ldap.cf)
  mailSubstituteOverridesLdap: false    # Enable to always use the value from mailSubstitute as user email
  attributeMappings:
    family_name: lastName               # LDAP attribute to use for family name (default value is sn)
    given_name: preferredName           # LDAP attribute to use for given name (default value is givenName)
# END

# BEGIN Include and customize the following lines to use groups-map-to-scopes or groups-as-scopes
#         (Requires using the search-and-bind binding method)
  groups:
    groupSearchFilter: 'member={0}'           # Used to find the groups a user (or group for nested search) belongs to
    searchBase: 'dc=local,dc=bluemix,dc=net'  # Specify if only part of the directory should be searched for groups
                                              #   Can be set to 'memberOf' if using Active Directory to skip group search
                                              #   and use calculated 'memberOf' field on user records
    maxSearchDepth: 2                         # Number of levels to search groups (default is 1 - no nested search)
    searchSubtree: true                       # Enable to search below the search base (default value is true)

    # BEGIN Include the following line to use groups-map-to-scopes
              profile_type: groups-map-to-scopes
    # END

    # BEGIN Include and customize the following lines to use groups-as-scopes
              profile_type: groups-as-scopes
              groupRoleAttribute: cloudFoundryScope  # Name of the LDAP attribute that holds a list (comma-separated)
                                                     #   of scope names applied to members of the group
    # END

# END

  ssl:
              skipverification: false  # Enable to skip server certificate validation when using LDAPS
              tls: none                # Use value 'simple' to enable StartTLS (default value is none)
            sslCertificate: |+         # Self-signed server certificate to be trusted if using LDAPS
              -----BEGIN CERTIFICATE-----
              <BASE64_ENCODED_CERT>
              -----END CERTIFICATE-----

これらの手順とサンプル構成は、LDAP 認証の最も一般的なオプションをカバーしています。 有効なすべてのプロパティーのリストについては、BOSH uaa ジョブ の uaa.ldap プロパティーを参照してください。 詳細については、User Account and Authentication LDAP Integration を参照してください。

構成マネージャー CLI を使用した cfp-ext-ldap 拡張機能のアクティブ化

  1. 以下のように、構成ファイルを inception コンテナーにプッシュします。<ldap_config_file> は、作成した LDAP 構成ファイルの名前です。

    ./cm extension -e cfp-ext-ldap save -c <ldap_config_file>
    
  2. メイン Cloud Foundry Enterprise Environment デプロイメントに拡張機能を挿入します。 以下のコマンドにより、Cloud Foundry Enterprise Environment コンポーネントのデプロイメント前に LDAP 拡張機能のデプロイメントを追加します。 LDAP 機能拡張が状態ファイル内の正しい場所に自動的に挿入されます。

    ./cm states insert -i cfp-ext-ldap
    
  3. 以下のように、エンジンをリセットします。

    ./cm engine reset
    

cfp-ext-ldap 拡張機能を使用した Cloud Foundry のデプロイ

Cloud Foundry deployment tool または構成マネージャー CLI を使用して cfp-ext-ldap 拡張機能を有効にして構成した後、影響を受けるコンポーネントを更新するために、Cloud Foundry のデプロイメントを再起動する必要があります。

Cloud Foundry deployment tool を使用して、メイン構成の「インストーラー・アクション」「アップグレード」に変更します。 「状態」ページの「デプロイメントの開始」をクリックします。

ユーザーのアクティブ化

手動でユーザーをアクティブ化することを選択した場合は、Cloud Foundry Enterprise Environment にアクセスする必要のあるユーザーごとに、次のコマンドを実行します。 <username> は、LDAP 構成内にある userDNPattern プロパティーまたは searchFilter プロパティー (選択したバインディング方式による) と一致する LDAP ユーザー ID です。

cf create-user <username> --origin ldap

ユーザー・アクセスの取り消し

手動でユーザーをアクティブ化することを選択した場合は、ユーザーのアカウントを削除することによって、そのユーザーのアクセス権限を取り消すことができます。

cf delete-user <username>

そうではなく、cf CLI を使用してユーザーを削除する方法以外でユーザー・アクセスを取り消すには、そのユーザーを LDAP から削除する必要があります。 あるいは、そのユーザーが LDAP バインディング構成の定義による基準に一致しなくなるように、そのユーザーが所属するグループのメンバーシップを変更する必要があります。

組織およびスペースへのユーザーの割り当て

LDAP ユーザーに特定の組織やスペースに対するアクセス権限が自動的に付与されることはありません。初回ログイン前に、まず最初に管理者が cf create-user <username> --origin ldap コマンドを使用してユーザーをアクティブ化した後、通常どおりに組織およびスペースの役割を割り当てることによって、アクセス権を付与できます。 詳しくは、『組織およびスペースに対するユーザー許可の管理』を参照してください。 LDAP レコードの情報に基づいて特定の組織やスペースに割り当てる必要のある LDAP ユーザーが多数存在する場合は、これらのアクションをスクリプト化しておくことができます。

LDAP グループと特権範囲のマッピング

groups-map-to-scopes を使用してグループ・メンバーシップに基づいて追加の特権範囲を LDAP ユーザーに自動的に割り当てることを選択した場合は、uaac CLI を使用してマッピングを管理できます。

  1. 次のコマンドを使用して uaac Ruby gem をインストールします。
    gem install cf-uaac
    
  2. インストール済み環境の UAA サーバーをターゲット指定します。 <bluemix_env_domain> を、インストール済み環境で使用する環境ドメインに置き換えます。 環境ドメインの証明書が自己署名証明書である場合は、コマンドに --skip-ssl-validation オプションを追加します。
    uaac target https://uaa.<bluemix_env_domain>
    
  3. UAA 管理者のクライアント秘密鍵を見つけます。 以下のコマンドを実行して、<uaa_admin_client_secret> の値を取得します。

    kubectl get -n uaa secret secrets -o jsonpath='{.data.uaa-admin-client-secret}' | base64 --decode
    

    UAA 管理者のクライアント秘密鍵を以下のコマンドに置換します。

    uaac token client get admin -s <uaa_admin_client_secret>
    

これで、以下の例に示すコマンドを発行することで、グループ・マッピングを管理できるようになりました。

uaac group mappings                      # 全グループ・マッピングをリスト
uaac group map --name <scope> <groupDN>  # LDAP グループの特権範囲と識別名 (DN) を指定して
                                         #   新規グループ・マッピングを作成
uaac group unmap <scope> <groupDN>       # LDAP グループの特権範囲と識別名 (DN) を指定して
                                         #   グループ・マッピングを削除
uaac user get <username>                 # ユーザー情報を取得して、どのグループがマッピング済みかを確認