LDAP 认证
概述
本文主要描述如何在平凯数据库使用 LDAP 认证。
创建 LDAP 用户
LDAP 认证现在支持 authentication_ldap_simple 和 authentication_ldap_sasl 两种身份认证插件。
CREATE USER 'betsy'@'localhost' IDENTIFIED WITH authentication_ldap_simple AS 'uid=betsy_ldap,ou=People,dc=example,dc=com';
CREATE USER 'boris'@'localhost' IDENTIFIED WITH authentication_ldap_sasl AS 'uid=boris_ldap,ou=People,dc=example,dc=com';
创建用户时 AS 'uid=betsy_ldap,ou=People,dc=example,dc=com' 是可选的。
使用 LDAP 用户进行认证
系统变量设置
| 系统变量名 | 描述 | 例子 | 默认值 |
|---|---|---|---|
| authentication_ldap_sasl_auth_method_name | SASL 认证方式使用的方法,当前支持 SCRAM-SHA-256, SCRAM-SHA-1, GSSAPI | SCRAM-SHA-256 | SCRAM-SHA-1 |
| authentication_ldap_simple_auth_method_name | SIMPLE 认证方式使用的认证方法,当前支持 SIMPLE | SIMPLE | SIMPLE |
| authenticationldap{sasl,simple}_ca_path | 用于验证 LDAP 服务器连接的 CA 证书 | /usr/share/tidb/ldap-ca.pem | NULL |
| authenticationldap{sasl,simple}_tls | 连接到 LDAP 服务器时是否开启 TLS | OFF | OFF |
| authenticationldap{sasl,simple}_init_pool_size | LDAP 连接池初始大小 | 1 | 10 |
| authenticationldap{sasl,simple}_max_pool_size | LDAP 连接池中连接的最大数量。设置为 0 表示关闭池化 | 10 | 1000 |
| authenticationldap{sasl,simple}_server_host | LDAP 服务器的主机名/IP 地址 | ldap.pingcap.com | |
| authenticationldap{sasl,simple}_server_port | LDAP 服务器的端口 | 389 | 389 |
| authenticationldap{sasl,simple}_bind_base_dn | 用于搜索用户的 dn,可以用限制平凯数据库的搜索范围 | ou=People,dc=example,dc=com | NULL |
| authenticationldap{sasl,simple}_bind_root_dn | 在 LDAP 服务器中搜索用户前,平凯数据库需要认证并绑定到 LDAP 服务器上,root_dn 和 root_pwd 用于认证与绑定。 root_dn 需要有足够的权限在 LDAP 服务器中搜索。 如果 root_dn 和 root_pwd 没有设置,则使用匿名进行认证。 | ou=uid=admin,dc=example,dc=com | NULL |
| authenticationldap{sasl,simple}_bind_root_pwd | 在 LDAP 服务器中搜索用户前,平凯数据库需要认证并绑定到 LDAP 服务器上,root_dn 和 root_pwd 用于认证与绑定。 root_dn 需要有足够的权限在 LDAP 服务器中搜索。 如果 root_dn 和 root_pwd 没有设置,则使用匿名进行认证。 | 123456 | NULL |
| authenticationldap{sasl,simple}_user_search_attr | 用于搜索的属性。比如,当设置为 uid 时,平凯数据库将在 LDAP 服务器中搜索 uid 与平凯数据库用户名相同的条目。 | cn | uid |