LDAP 身份验证示例

本节介绍如何在 Driverless AI 中启用`轻型目录访问协议 <https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol>`__ . 在启动 Driverless AI Docker 映像时,可以将可用参数指定为环境变量,也可以通过用于本机安装的 config.toml 文件设置这些参数。完成后,已配置 LDAP 中的所有用户均应能登录至 Driverless AI 并能执行实验运行、数据集可视化、模型解释等操作。

请注意:Driverless AI 不支持 LDAP 客户端身份验证。如果您已启用 LDAP 客户端身份验证,则 Driverless AI LDAP 连接器将无法使用。

配置属性说明

在启用 LDAP 身份验证时,可指定以下选项。

  • ldap_server: LDAP 服务器域或 IP。

  • ldap_port: LDAP 服务器端口。

  • ldap_bind_dn: LDAP 绑定用户的完整可分辨名称 (DN)。

  • ldap_bind_password: LDAP 绑定密码。

  • ldap_tls_file: 传输层安全协议 (TLS) 证书文件位置。

  • ldap_use_ssl: 启用 (TRUE) 或禁用 (FALSE) SSL。

  • ldap_search_base: 在目录信息树 (DIT) 中开始搜索的位置。

  • ldap_search_filter: 描述搜索对象的字符串。您可以使用 Python 替换功能来进行动态构建。(仅支持 {{DAI_USERNAME}}。例如,”(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))”.)

  • Ldap_search_attributes: 搜索返回的 LDAP 属性。

  • ldap_user_name_attribute="uid": 指定用于查找用户名的密钥。

不使用 SSL 的 LDAP

以下示例介绍在 Docker 映像中或通过本机安装运行 Driverless AI 时,如何启用不使用 SSL 的 LDAP。如果配置和身份验证成功,用户即可访问 Driverless AI 并执行实验运行、数据集可视化、模型解释等操作。

以下示例展示了如何在启动 Driverless AI Docker 映像时配置不使用 SSL 的 LDAP。

nvidia-docker run \
  --pid=host \
  --init \
  --rm \
  --shm-size=256m \
  -p 12345:12345 \
  -u `id -u`:`id -g` \
  -e DRIVERLESS_AI_ENABLED_FILE_SYSTEMS="file,s3,hdfs" \
  -e DRIVERLESS_AI_AUTHENTICATION_METHOD="ldap" \
  -e DRIVERLESS_AI_LDAP_USE_SSL="false" \
  -e DRIVERLESS_AI_LDAP_SERVER="ldap.forumsys.com" \
  -e DRIVERLESS_AI_LDAP_PORT="389" \
  -e DRIVERLESS_AI_LDAP_SEARCH_BASE="dc=example,dc=com" \
  -e DRIVERLESS_AI_LDAP_BIND_DN="cn=read-only-admin,dc=example,dc=com" \
  -e DRIVERLESS_AI_LDAP_BIND_PASSWORD=password \
  -e DRIVERLESS_AI_LDAP_SEARCH_FILTER="(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))" \
  -e DRIVERLESS_AI_LDAP_USER_NAME_ATTRIBUTE="uid" \
  -v `pwd`/data:/data \
  -v `pwd`/log:/log \
  -v `pwd`/license:/license \
  -v `pwd`/tmp:/tmp \
  h2oai/dai-centos7-x86_64:1.9.2.1-cuda10.0.xx

以下示例展示了如何在从本机安装中启动 Driverless AI 时配置不使用 SSL 的 LDAP。本机安装包括 DEB、RPM 和 TAR SH 安装。

  1. 导出 Driverless AI config.toml 文件或将其添加至 ~/.bashrc。例如:

# DEB and RPM
export DRIVERLESS_AI_CONFIG_FILE="/etc/dai/config.toml"

# TAR SH
export DRIVERLESS_AI_CONFIG_FILE="/path/to/your/unpacked/dai/directory/config.toml"
  1. 启用不使用 SSL 的 LDAP 身份验证。

# Enable LDAP authentication
authentication_method = "ldap"

# Specify the LDAP server domain or IP to connect to
ldap_server = "ldap.forumsys.com"

# Specify the LDAP port to connect to
ldap_port = "389"

# Disable SSL
ldap_use_ssl="false"

# Specify the location in the DIT where the search will start
ldap_search_base = "dc=example,dc=com"

# Specify the LDAP search filter
# This is A string that describes what you are searching for. You
# can use Python substitution to have this constructed dynamically.
# (Only {{DAI_USERNAME}} is supported. For example, "(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))".)
ldap_search_filter = "(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))"

# Specify the complete DN of the LDAP bind user
ldap_bind_dn = "cn=read-only-admin,dc=example,dc=com"

# Specify the LDAP password for the above user
ldap_bind_password = "password"

# Specify a key to find the user name
ldap_user_name_attribute = "uid"
  1. 启动(或重启)Driverless AI。请注意,用于启动 Driverless AI 的命令将因安装类型而异。

# Linux RPM or DEB with systemd
sudo systemctl start dai

# Linux RPM or DEB without systemd
sudo -H -u dai /opt/h2oai/dai/run-dai.sh

# Linux TAR SH
./run-dai.sh

如果身份验证成功,用户即可访问 Driverless AI 并执行实验运行、数据集可视化、模型解释等操作。

使用 SSL 的 LDAP

以下示例展示了在启动 Driverless AI Docker 映像时如何启用使用 SSL 和其他参数(可指定为环境变量或可通过用于本地安装的 config.toml 文件进行设置)的 LDAP 身份验证。完成后,已配置 LDAP 中的所有用户均应该能登录至 Driverless AI 并执行实验运行、数据集可视化、模型解释等操作。

启动 Driverless AI Docker 映像时指定以下 LDAP 环境变量。此示例启用了 LDAP 身份验证并展示了如何指定启用 SSL 的其他选项。

nvidia-docker run \
 --pid=host \
 --init \
 --rm \
 --shm-size=256m \
 -p 12345:12345 \
 -u `id -u`:`id -g` \
 -e DRIVERLESS_AI_ENABLED_FILE_SYSTEMS="file,s3,hdfs" \
 -e DRIVERLESS_AI_AUTHENTICATION_METHOD="ldap" \
 -e DRIVERLESS_AI_LDAP_SERVER="ldap.forumsys.com" \
 -e DRIVERLESS_AI_LDAP_PORT="389" \
 -e DRIVERLESS_AI_LDAP_SEARCH_BASE="dc=example,dc=com" \
 -e DRIVERLESS_AI_LDAP_SEARCH_FILTER="(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))" \
 -e DRIVERLESS_AI_LDAP_USE_SSL="true" \
 -e DRIVERLESS_AI_LDAP_TLS_FILE="/tmp/abc-def-root.cer" \
 -e DRIVERLESS_AI_LDAP_LDAP_BIND_DN="cn=read-only-admin,dc=example,dc=com" \
 -e DRIVERLESS_AI_LDAP_LDAP_BIND_PASSWORD="password" \
 -e DRIVERLESS_AI_LDAP_USER_NAME_ATTRIBUTE="uid" \
 -v `pwd`/data:/data \
 -v `pwd`/log:/log \
 -v `pwd`/license:/license \
 -v `pwd`/tmp:/tmp \
 h2oai/dai-centos7-x86_64:1.9.2.1-cuda10.0.xx

本机安装包括 DEB、RPM 和 TAR SH 安装。

  1. 导出 Driverless AI config.toml 文件或将其添加至 ~/.bashrc。例如:

# DEB and RPM
export DRIVERLESS_AI_CONFIG_FILE="/etc/dai/config.toml"

# TAR SH
export DRIVERLESS_AI_CONFIG_FILE="/path/to/your/unpacked/dai/directory/config.toml"
  1. 启用使用 SSL 的 LDAP 身份验证。

# Enable LDAP authentication
authentication_method = "ldap"

# Specify the LDAP server domain or IP to connect to
ldap_server = "ldap.forumsys.com"

# Specify the LDAP port to connect to
ldap_port = "389"

# Specify the location in the DIT where the search will start
ldap_search_base = "dc=example,dc=com"

# Specify the LDAP search filter
# This is a string that describes what you are searching for. You
# can use Python substitution to have this constructed dynamically.
# (Only {{DAI_USERNAME}} is supported.)
ldap_search_filter = "(&(objectClass=person)(cn:dn:={{DAI_USERNAME}}))"

# If the LDAP connection to the LDAP server needs an SSL certificate,
# then this needs to be specified
ldap_use_ssl = "True"

# Specify the LDAP TLS file location if SSL is set to True
ldap_tls_file = "/tmp/abc-def-root.cer"

# Complete DN of the LDAP bind user
ldap_bind_dn = "cn=read-only-admin,dc=example,dc=com"

# Specify the LDAP password for the above user
ldap_bind_password = "password"

# Specify a key to find the user name
ldap_user_name_attribute = "uid"
  1. 启动(或重启)Driverless AI。用户目前可使用其 LDAP 凭证来启动 Driverless AI。请注意,用于启动 Driverless AI 的命令将因安装类型而异。

# Linux RPM or DEB with systemd
sudo systemctl start dai

# Linux RPM or DEB without systemd
sudo -H -u dai /opt/h2oai/dai/run-dai.sh

# Linux TAR SH
./run-dai.sh

如果身份验证成功,用户即可访问 Driverless AI 并执行实验运行、数据集可视化、模型解释等操作。