跳到主要内容
版本:3.10.x

为开发者门户配置 SSO

开发者门户通过外部身份提供商支持单点登录(SSO),允许开发者使用现有组织凭证进行身份验证。SSO 在提供商门户中配置为登录选项,与控制台 SSO 配置分开。

先决条件

按照管理 Token创建 Token 并导出:

export API_KEY="a7ee-xxxxxxxxxxxxx"

支持的协议

协议描述
OIDCOpenID 连接。与 Keycloak、Okta、Auth0 和 Azure AD 等提供商集成。
SAML安全断言标记语言 2.0。与企业身份提供商集成。
LDAP轻量级目录访问协议。与 Active Directory 等目录服务集成。
CAS中央身份验证服务。与 CAS 服务器集成。

创建登录选项

OIDC

curl -k "https://localhost:7443/api/login_options" \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "Okta SSO",
"provider_type": "oidc",
"disable": false,
"config": {
"issuer": "https://your-org.okta.com",
"client_id": "<oidc-client-id>",
"client_secret": "<oidc-client-secret>",
"request_scopes": ["openid", "profile", "email"],
"ssl_verify": true,
"attributes": {
"username": "preferred_username",
"email": "email",
"name": "name"
}
}
}'

如果你不在本地运行,请将 localhost 替换为你的仪表板主机。如果仪表板使用自签名 TLS 证书,则需要 -k 标志。

name 是登录页面上向开发者显示的显示名称。

provider_type 选择SSO 协议。对于 OpenID Connect 提供商(例如 Okta、Auth0 或 Keycloak)使用 oidc

disable: false 创建后立即启用登录选项。

config.issuer 是用于发现的 OIDC 发行者 URL。

config.client_idconfig.client_secret 是你的身份提供商颁发的 OAuth 客户端凭证。

config.attributes 将身份提供商声明映射到开发者字段,例如用户名、电子邮件和姓名。

SAML

curl -k "https://localhost:7443/api/login_options" \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "Corporate SAML",
"provider_type": "saml",
"disable": false,
"config": {
"entity_id": "https://portal.example.com",
"idp_metadata_url": "https://idp.example.com/metadata",
"sign_request": true,
"attributes": {
"username": "urn:oid:0.9.2342.19200300.100.1.1",
"email": "urn:oid:0.9.2342.19200300.100.1.3",
"name": "urn:oid:2.5.4.3"
}
}
}'

name 是登录页面上向开发者显示的显示名称。

provider_type: "saml"选择SAML 2.0作为认证协议。

disable: false 创建后立即启用登录选项。

config.entity_id 是门户使用的服务提供商实体 ID。

config.idp_metadata_url 指向 API7 用于配置 SAML 集成的 IdP 元数据文档。

config.attributes 将 SAML 属性映射到开发者字段。

LDAP

curl -k "https://localhost:7443/api/login_options" \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "Active Directory",
"provider_type": "ldap",
"disable": false,
"config": {
"host": "ldap.example.com",
"port": 636,
"base_dn": "dc=example,dc=com",
"bind_dn": "cn=admin,dc=example,dc=com",
"bind_password": "<ldap-password>",
"identifier": "uid",
"use_ssl": true,
"ssl_verify": true,
"attributes": {
"username": "uid",
"email": "mail",
"name": "cn"
}
}
}'

name 是登录页面上向开发者显示的显示名称。

provider_type: "ldap" 选择LDAP 认证。

disable: false 创建后立即启用登录选项。

config.hostconfig.portconfig.base_dnconfig.bind_dnconfig.bind_password 定义 API7 如何连接到并搜索你的LDAP 目录。

config.identifier 选择 LDAP 属性作为登录标识,例如 uidsAMAccountName

config.attributes 将 LDAP 属性映射到开发者字段。

CAS

curl -k "https://localhost:7443/api/login_options" \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "CAS Server",
"provider_type": "cas",
"disable": false,
"config": {
"url": "https://cas.example.com/cas",
"send_service": true,
"ssl_verify": true,
"attributes": {
"username": "uid",
"email": "mail",
"name": "cn"
}
}
}'

name 是登录页面上向开发者显示的显示名称。

provider_type: "cas" 选择CAS 作为认证协议。

disable: false 创建后立即启用登录选项。

config.url 是 CAS 服务器的基础 URL。

config.send_service 控制API7 请求中是否包含service 参数。

config.attributes 将 CAS 属性映射到开发者字段。

管理登录选项

启用/禁用

切换登录选项而不删除其配置:

curl -k -X PATCH "https://localhost:7443/api/login_options/{login_option_id}" \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '[
{
"op": "replace",
"path": "/disable",
"value": true
}
]'

删除

curl -k -X DELETE "https://localhost:7443/api/login_options/{login_option_id}" \
-H "X-API-KEY: ${API_KEY}"
备注

至少一个登录选项必须始终保持启用状态。内置登录选项可以禁用但不能删除。

敏感字段处理

敏感字段(client_secretprivate_keybind_passwordclient_key)在创建后在 API 响应中被屏蔽。要更新敏感字段,请在更新请求中包含新值。支持 $env://VAR_NAME 语法的字段可以引用环境变量,而不是直接包含密钥。

开发者通过SSO认证

通过 SSO 登录选项进行身份验证的开发者的 provider 字段设置为 sso。他们的账户是在首次登录时自动创建的,配置文件信息是根据身份提供商属性填充的。

其他资源