OIDC 管理

该平台支持 OIDC(OpenID Connect)协议,完成 OIDC 配置后,平台管理员可以使用第三方账号登录。平台管理员还可以更新和删除已配置的 OIDC 服务。

OIDC 概述

OIDC(OpenID Connect)是基于 OAuth 2.0 协议的身份认证标准协议。它使用 OAuth 2.0 授权服务器为第三方客户端提供用户身份认证,并将相应的身份认证信息传递给客户端。

OIDC 允许各种类型的客户端(包括服务端、移动端和 JavaScript 客户端)请求并接收已认证会话和最终用户信息。该规范套件具有可扩展性,当有意义时,参与方可以使用可选功能,例如身份数据加密、OpenID Provider 发现以及会话管理。更多信息请参阅 OIDC 官方文档

添加 OIDC

通过添加 OIDC,您可以使用第三方平台账号登录平台。

注意:OIDC 用户成功登录平台后,平台将使用用户的 email 属性作为唯一标识符。支持 OIDC 的第三方平台用户必须具备 email 属性,否则将无法登录平台。

操作步骤

  1. 在左侧导航栏中,单击 Users > IDPs

  2. 单击 Add OIDC

  3. 配置 Basic Information 参数。

  4. 配置 OIDC Server Configuration 参数:

    • Identity Provider URL:Issuer URL,即 OIDC identity provider 的访问地址。

    • Client ID:OIDC client 的客户端标识符。

    • Client Secret:OIDC client 的密钥。

    • Redirect URI:登录第三方平台后的回调地址,即 dex issuer 的 URL + /callback

    • Logout URL:执行 Logout 操作后用户访问的地址。如果为空,则注销地址为平台的初始登录页面。

  5. IDP Service Configuration Validation 区域,输入有效 OIDC 账号的 UsernamePassword,用于验证配置。

    提示:如果用户名和密码不正确,添加时将报错,提示凭证无效,且无法添加 OIDC。

  6. 单击 Create

通过 YAML 添加 OIDC

除了表单配置外,平台还支持通过 YAML 添加 OIDC,这样可以更灵活地配置认证参数、claim 映射、用户组同步以及其他高级功能。

示例:配置 OIDC Connector

以下示例演示如何配置一个 OIDC connector,用于集成 OIDC 身份认证服务。此配置示例适用于以下场景:

  1. 需要将 OIDC 集成为身份认证服务器。

  2. 需要支持用户组信息同步。

  3. 需要自定义注销重定向地址。

  4. 需要配置特定的 OIDC scopes。

  5. 需要自定义 claim 映射。

apiVersion: dex.coreos.com/v1
kind: Connector
# Connector basic information
id: oidc               # Connector unique identifier
name: oidc             # Connector display name
type: oidc             # Connector type is OIDC
metadata:
  annotations:
    cpaas.io/description: "11"  # Connector description
  name: oidc
  namespace: cpaas-system
spec:
  config:
    # OIDC server configuration
    # Configure server connection information, including server address, client credentials, and callback address
    issuer: http://auth.com/auth/realms/master               # OIDC server address
    clientID: dex                                            # Client ID
    # Service account secret key, valid when creating Connector resources for the first time
    clientSecret: xxxxxxx
    redirectURI: https://example.com/dex/callback            # Callback address, must match the address registered by the OIDC client

    # Security configuration
    # Configure SSL verification and user information acquisition method
    insecureSkipVerify: true                                # Whether to skip SSL verification, it is recommended to set to false in a production environment
    getUserInfo: false                                      # Whether to obtain additional user information through the UserInfo endpoint

    # Logout configuration
    # Configure the redirect address after user logout
    logoutURL: https://test.com                            # Logout redirect address, can be customized to the page jumped after user logout

    # Scope configuration
    # Configure the required authorization scope, ensure that the OIDC server supports these scopes
    scopes:
      - openid                                             # Required, used for OIDC basic authentication
      - profile                                            # Optional, used to obtain user basic information
      - email                                              # Optional, used to obtain user email

    # Claim mapping configuration
    # Configure the mapping relationship between OIDC returned claims and platform user attributes
    overrideClaimMapping: false                          # Whether to enforce the claimMapping rules when standard claims are also returned
    claimMapping:
      email: email                                         # Email mapping, used for user unique identification
      groups: groups                                       # Group claim mapping. For non-standard claims, set it to the actual key, such as "cognito:groups"
      phone: ""                                            # Phone mapping, optional
      preferred_username: preferred_username               # Username mapping, used for display name

    # User group configuration
    # Configure user group synchronization related parameters, ensure that the token contains group information
    groupsKey: groups                                      # Key name used to read group data. Keep it consistent with claimMapping.groups
    insecureEnableGroups: false                           # Whether to enable group synchronization (group claims may be stale until ID token refresh)

与 OIDC 用户组相关的字段

当需要从 OIDC provider 同步用户组时,请同时配置以下字段:

字段描述
overrideClaimMapping控制 claimMapping 中的映射是否覆盖默认的 claim 选择行为。当您的 provider 同时返回标准和非标准 claim,并且您希望强制使用自定义映射时,请将其设置为 true
claimMapping.groups将 provider 的某个 claim 映射为平台使用的标准 groups claim。如果您的 provider 返回的是非标准键(例如 cognito:groups),请将此字段设置为该键。
groupsKey指定用于读取组数据进行同步的 claim key。为避免不匹配,请使用与 claimMapping.groups 相同的值。
insecureEnableGroups启用 OIDC 登录的 group-claim 处理。仅当您需要组同步且 provider 返回 group claims 时才应启用。

注意

  • 如果 provider 需要显式的 group scope,请在 scopes 中包含 groups
  • 除非将 overrideClaimMapping 设置为 true,否则 claimMapping 可能不会覆盖 provider 返回的标准 claims。
  • group claims 会随着 ID token 刷新而刷新。provider 侧的组成员变更可能不会立即生效。

相关操作

您可以在列表页点击右侧的 ,也可以在详情页右上角点击 Actions,按需更新或删除 OIDC。

操作描述
Update OIDC更新已添加的 OIDC 配置。更新 OIDC 配置信息后,原有用户和认证方式将根据当前配置重新重置并同步。
Delete OIDC删除平台不再使用的 OIDC。删除 OIDC 后,所有通过此 OIDC 同步到平台的用户状态将变为 无效(用户与角色的绑定关系保持不变),且无法登录平台。重新集成后,用户可通过成功登录平台被激活。

提示:删除 IDP 后,如果需要删除通过 OIDC 同步到平台的用户和用户组,请勾选提示框下方的 Clean IDP Users and User Groups 复选框。