LDAP 认证

概述

本文主要描述如何在平凯数据库使用 LDAP 认证。

创建 LDAP 用户

LDAP 认证现在支持 authentication_ldap_simpleauthentication_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_nameSASL 认证方式使用的方法,当前支持 SCRAM-SHA-256, SCRAM-SHA-1, GSSAPISCRAM-SHA-256SCRAM-SHA-1
authentication_ldap_simple_auth_method_nameSIMPLE 认证方式使用的认证方法,当前支持 SIMPLESIMPLESIMPLE
authenticationldap{sasl,simple}_ca_path用于验证 LDAP 服务器连接的 CA 证书/usr/share/tidb/ldap-ca.pemNULL
authenticationldap{sasl,simple}_tls连接到 LDAP 服务器时是否开启 TLSOFFOFF
authenticationldap{sasl,simple}_init_pool_sizeLDAP 连接池初始大小110
authenticationldap{sasl,simple}_max_pool_sizeLDAP 连接池中连接的最大数量。设置为 0 表示关闭池化101000
authenticationldap{sasl,simple}_server_hostLDAP 服务器的主机名/IP 地址ldap.pingcap.com
authenticationldap{sasl,simple}_server_portLDAP 服务器的端口389389
authenticationldap{sasl,simple}_bind_base_dn用于搜索用户的 dn,可以用限制平凯数据库的搜索范围ou=People,dc=example,dc=comNULL
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=comNULL
authenticationldap{sasl,simple}_bind_root_pwd在 LDAP 服务器中搜索用户前,平凯数据库需要认证并绑定到 LDAP 服务器上,root_dn 和 root_pwd 用于认证与绑定。 root_dn 需要有足够的权限在 LDAP 服务器中搜索。 如果 root_dn 和 root_pwd 没有设置,则使用匿名进行认证。123456NULL
authenticationldap{sasl,simple}_user_search_attr用于搜索的属性。比如,当设置为 uid 时,平凯数据库将在 LDAP 服务器中搜索 uid 与平凯数据库用户名相同的条目。cnuid