为 IBM Cloud Private Cloud Foundry 配置 LDAP 认证
您可以使用 LDAP 认证进行 IBM Cloud Private Cloud Foundry 中的用户认证。
您可以按照这些指示信息来配置 LDAP 认证,然后在 IBM Cloud Private Cloud Foundry 安装期间(请参阅安装 IBM Cloud Private Cloud Foundry)或安装后的任何时间运行 launch_deployment.sh 脚本。 通过将包含的扩展 cfp-ext-ldap 添加到主 IBM Cloud Private
Cloud Foundry 部署来完成配置。 请参阅在 IBM® Cloud Private Cloud Foundry 中使用扩展。 cfp-ext-ldap 扩展修改用户帐户和认证 (UAA) 服务器的部署属性。
配置 LDAP 认证之前,您必须在 LDAP 或 Active Directory 域中创建用户。 您可以使用组来过滤对 IBM Cloud Private Cloud Foundry 环境的访问权。
准备配置
LDAP 配置存储在 YAML 格式的文件中,该文件在这些指示信息中被称为 <ldap_config_file>。 创建文件(如 ldapconfig.yml),并将配置详细信息放在 uiconfig: 部分中,如示例配置中所示。
要配置 LDAP 认证,您必须作出以下选择:
-
LDAP 绑定方法
-
简单绑定
如果用户的专有名称 (DN) 格式已知并包含想要用作用户名的标识,请使用简单绑定配置并提供一个或多个要构建的 DN 模式。 UAA 构建 DN,然后尝试使用用户提供的密码来认证。 在示例配置中对适用行进行标记。
-
搜索和绑定
如果用户的 DN 格式未知或变化,您可以使用搜索 LDAP 以找到匹配用户的搜索和绑定配置。 使用搜索和绑定的一个常见原因是,是否要使用电子邮件地址作为用户名,并且 LDAP 服务器上用户记录的通用名称 (CN) 不包含电子邮件地址。 在此情况下,您需要为具有服务器访问权(最好是只读访问权)的 LDAP 用户提供用户名和密码,以检索记录并搜索该用户的匹配项。 如果针对该搜索过滤器正好有一个匹配项,那么 UAA 尝试使用用户提供的密码来认证。 在示例配置中对适用行进行标记。 通过在命令
ldapsearch -H <url> -D <userDN> -w <userPassword> -b <searchBase> <searchFilter>中替换配置值并将<searchFilter>值中的 {0} 替换为实际用户名来测试配置值。
-
-
组映射
-
缺省情况下,LDAP 用户具有以下权限范围:
cloud_controller.read cloud_controller.write cloud_controller_service_permissions.read notification_preferences.read notification_preferences.write oauth.approvals openid password.write profile roles scim.me uaa.offline_token uaa.user user_attributes如果要根据 LDAP 用户的组成员资格向其授予其他权限范围,有两个选项:
-
groups-map-as-scopes
使用
uaacCLI 来管理 LDAP 组和权限范围之间的映射。 每次用户登录时都重新计算范围,因此您可以使用uaac取消映射组来除去权限。 -
groups-as-scopes
在 LDAP 组的属性值中指定权限范围。 这需要对 LDAP 服务器的管理访问权。
-
-
- 激活方法
- 缺省情况下,可使用所选 LDAP 绑定方法认证的所有用户都将在其首次登录 IBM Cloud Private Cloud Foundry 时自动激活。 如果您更愿意允许已手动激活的用户登录,请将
add_shadow_user_on_login设置为false。
- 缺省情况下,可使用所选 LDAP 绑定方法认证的所有用户都将在其首次登录 IBM Cloud Private Cloud Foundry 时自动激活。 如果您更愿意允许已手动激活的用户登录,请将
示例配置
uiconfig:
instance_groups:
- name: uaa
jobs:
- name: uaa
properties:
uaa:
ldap:
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
# (Requires using the search-and-bind binding method)
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
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 属性。 有关更多详细信息,请参阅用户帐户和认证 LDAP 集成。
使用 cfp-ext-ldap 扩展部署 IBM Cloud Private Cloud Foundry
-
向 Inception 容器推送配置文件
<ldap_config_file>是您创建的 LDAP 配置文件的名称:./cm extension -e cfp-ext-ldap save -c <ldap_config_file> -
将扩展插入主 IBM Cloud Private Cloud Foundry 部署中。 在部署 IBM Cloud Private Cloud Foundry 组件之前,使用以下命令添加 LDAP 扩展的部署。 LDAP 扩展自动插入到状态文件中的正确位置。
./cm states insert -i cfp-ext-ldap -
重置引擎:
./cm engine reset -
重新启动 IBM Cloud Private Cloud Foundry 部署进程。
<cf_config_file>是 IBM Cloud Private Cloud Foundry 部署的主要配置文件,例如uiconfig.yml:./launch_deployment.sh -c <cf_config_file>
激活用户
如果您选择手动激活用户,那么针对需要访问 IBM Cloud Private Cloud Foundry 的每个用户,运行以下命令。<username> 是与 LDAP 配置中的 userDNPattern 或 searchFilter 属性匹配的 LDAP 用户标识,具体取决于您选择的绑定方法:
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 来管理这些映射。
- 通过使用以下命令,安装
uaacRuby gem:gem install cf-uaac - 将 UAA 服务器作为安装的目标。 将
<bluemix_env_domain>替换为用于安装的环境域。 如果您的环境域证书是自签名的,将--skip-ssl-validation选项添加到该命令。uaac target https://uaa.<bluemix_env_domain> - 通过在文件
<data_directory>/CloudFoundry/deployment-vars.yml中找到uaa_admin_client_secret值并将其代入以下命令,使用uaacCLI 登录:uaac token client get admin -s <uaa_admin_client_secret>
通过发出以下示例中所示的命令,您可以管理组映射:
uaac group mappings # List all group mappings
uaac group map --name <scope> <groupDN> # Create a new group mapping by specifying the privilege scope
# and distinguished name (DN) of the LDAP group
uaac group unmap <scope> <groupDN> # Delete a group mapping by specifying the privilege scope
# and distinguished name (DN) of the LDAP group
uaac user get <username> # Retrieve user information to verify which groups have been mapped