如何接入LDAP&OIDC

接入LDAP、OIDC有两种方式;

  1. 在集群安装时,配置OIDC认证信息,关于OIDC配置信息,请参考Configuring the API Server

installer-oidc

  1. 集群安装完成后,可以通过调用API的形式切换认证模式为OIDC或LDAP

    a. 修改auth配置文件,configmap: tke-auth-api,指定默认idp类型为ldap:

    1. "auth": {
    2. "init_tenant_type": "ldap", // 指定ldap类型的idp
    3. "init_tenant_id": "ldap-test", // tenant id
    4. "init_idp_administrators": ["jane"], //idp的管理员列表,需要存在客户ldap系统中,具有平台的超级管理员权限
    5. "ldap_config_file":"_debug/auth-ldap.json",
    6. }

    b. 准备ldap配置文件,配置说明参见:dex-ldap

    1. {
    2. //ldap地址,host:port
    3. "host": "localhost:389",
    4. "insecureNoSSL": true, // 是否开始SSL,如果host没有指定端口,ture,端口为389和false, 端口为636
    5. "bindDN": "cn=admin,dc=example,dc=org", //服务账户的DN和密码,用来查询ldap用户组和用户
    6. "bindPW": "admin", //密码
    7. "usernamePrompt": "User Name", //
    8. "userSearch": {
    9. "baseDN": "ou=People,dc=example,dc=org", //用户baseDN
    10. "filter": "(objectClass=person)", //查询过滤条件
    11. "username": "cn", // username的属性key,cn=jane,ou=People,dc=example,dc=org
    12. "idAttr": "DN", // user id的属性key
    13. "emailAttr": "mail", // 邮件属性key
    14. "nameAttr": "cn" //displayname 的属性key
    15. },
    16. "groupSearch": {
    17. "baseDN": "ou=Groups,dc=example,dc=org",//用户组baseDN
    18. "filter": "(objectClass=groupOfNames)", //查询过滤条件
    19. "userAttr": "DN", //用户组成员id属性key
    20. "groupAttr": "member", //用户组成员key
    21. "nameAttr": "cn" //用户组名称key
    22. }
    23. }

    c. 调用API,新增ldap idp,

    1. curl -XPOST https://{auth_address}/apis/auth.tkestack.io/v1/identityproviders -H 'Authorization: Bearer {admin_token}' -H 'Content-Type: application/json'

    ​ Body:

    1. {
    2. "metadata": {
    3. "name": "ldap-test" //tennatID
    4. },
    5. "spec": {
    6. "name": "ldap-test",
    7. "type": "ldap",
    8. "administrators": [ //超级管理员
    9. "jane"
    10. ],
    11. "config": " {\"host\":\"localhost:389\",\"insecureNoSSL\":true,\"bindDN\":\"cn=admin,dc=example,dc=org\",\"bindPW\":\"admin\",\"usernamePrompt\":\"Email Address\",\"userSearch\":{\"baseDN\":\"ou=People,dc=example,dc=org\",\"filter\":\"(objectClass=person)\",\"username\":\"cn\",\"idAttr\":\"DN\",\"emailAttr\":\"mail\",\"nameAttr\":\"cn\"},\"groupSearch\":{\"baseDN\":\"ou=Groups,dc=example,dc=org\",\"filter\":\"(objectClass=groupOfNames)\",\"userAttr\":\"DN\",\"groupAttr\":\"member\",\"nameAttr\":\"cn\"}}" //ldap配置
    12. }
    13. }

d. 删除IDP

  1. curl -XDELETE https://{auth_address}/apis/auth.tkestack.io/v1/identityproviders/ldap-test -H 'Authorization: Bearer {admin_token}'