KubeSphere 企业版支持设置外部身份验证,平台管理员可以通过 secret(保密字典)配置身份提供者。

配置外部身份提供者后,允许使用 LDAP、CAS、GitHub、阿里云 IDaas、或 OpenID Connect 的用户名和密码登录 KubeSphere 企业版 Web 控制台。

操作步骤

  1. 以具有 platform-admin 角色的用户登录 KubeSphere 企业版 Web 控制台。

  2. 点击集群管理,并进入 host 集群。

  3. 在左侧导航栏选择配置 > 保密字典

  4. 在页面点击创建

  5. 创建保密字典对话框,点击右上角的编辑 YAML 开关,使用 yaml 创建保密字典。

  6. 按照以下示例及配置说明修改 yaml 文件,配置完成后,点击创建

  7. 登出 KubeSphere 企业版 Web 控制台,在登录页面,根据配置的外部身份验证类型,输入 LDAP、CAS、GitHub、阿里云 IDaas、或 OpenID Connect 的用户名和密码登录。

说明

多集群环境中,只需要在主集群中进行配置。

OpenLDAP 示例 yaml

apiVersion: v1
kind: Secret
metadata:
  namespace: kubesphere-system  # 请勿修改
  name: identity-provider-ldap  # 确保该 Secret 名称在 Kubernetes 集群中唯一
  labels:
    config.kubesphere.io/type: identityprovider # 请勿修改
    config.kubesphere.io/identityprovider: openldap # 与 configuration.yaml 中的 name 字段保持一致
type: config.kubesphere.io/identityprovider # 请勿修改

stringData:
  configuration.yaml: |
    name: openldap
    type: LDAPIdentityProvider
    mappingMethod: auto
    hidden: false
    disabled: false
    displayName: "Third-party login for LDAP"
    provider:
      host: "192.168.0.2:389"
      managerDN: uid=root,cn=users,dc=nas
      managerPassword: "********"
      userSearchBase: cn=users,dc=nas
      loginAttribute: uid
      mailAttribute: mail
      displayNameAttribute: displayName
注意
  • secret 必须创建在 kubeshere-system 项目中。

  • secret 必须包含 label。

    config.kubesphere.io/type: identityprovider

  • secret 必须包含 type。

    type: config.kubesphere.io/identityprovider

参数说明

上述示例的 stringData:configuration.yaml 参数中:

  • name: 指定外部身份验证的名称,必须唯一,否则会创建失败。必须与 label 中 config.kubesphere.io/identityprovider 的值保持一致。

  • type: 指定外部身份验证的类型,支持以下类型:

    • LDAP: LDAPIdentityProvider

    • CAS: CASIdentityProvider

    • GitHub: GitHubIdentityProvider

    • 阿里云 IDaas: AliyunIDaaSProvider

    • OpenID Connect: OIDCIdentityProvider

  • mappingMethod: 指定外部身份用户与 KubeSphere 企业版用户的关联方式。

    • auto: 自动创建相同名称的 KubeSphere 企业版用户,当平台中已存在名称时会创建失败。

    • manual: 登录后创建一个任意名称的新用户。

    • lookup: 自动关联已存在的具有相同名称的 KubeSphere 企业版用户,如果不存在该名称的用户,则创建失败。

  • hidden: 是否隐藏前端登录选项。默认为 false。

  • disabled: 是否禁用该登录方式。默认为 false。

  • displayName: 登录选项的展示名称。

  • provider: 身份提供者信息。身份提供者会对用户进行验证,并向 KubeSphere 提供身份令牌。以下是不同身份提供者的 provider 参数示例。

    • LDAPIdentityProvider

      host: 192.168.0.2:389
      managerDN: uid=root,cn=users,dc=nas
      managerPassword: "********"
      userSearchBase: cn=users,dc=nas
      loginAttribute: uid
      mailAttribute: mail

      有关 LDAP 的更多配置信息,请参阅 LDAP/LDAPS 身份验证

    • OIDCIdentityProvider

      issuer: https://accounts.google.com
      clientID: "your-client-id"
      clientSecret: "your-client-secret"
      redirectURL: "https://your-app.com/oauth/callback"

      有关 OIDC 的更多配置信息,请参阅 OIDC 身份验证

    • CASIdentityProvider

      redirectURL: "https://your-app.com/cas/callback"
      casServerURL: "https://cas.example.com/cas"

      有关 CAS 的更多配置信息,请参阅 CAS 身份验证

    • GitHubIdentityProvider

      clientID: '******'
      clientSecret: '******'
      redirectURL: 'https://ks-console/oauth/redirect/github'
    • 阿里云 IDaaS 身份提供者的配置方法,请参阅阿里云 IDaaS 文档