OIDC 端点参考

Keycloak 为每个 Realm 提供一组标准的 OpenID Connect 和 OAuth 2.0 端点。所有端点都可通过 OIDC 发现文档进行发现。

发现端点

GET https://<keycloak-host>/realms/<realm>/.well-known/openid-configuration

返回一个 JSON 文档,列出所有可用端点、受支持的 scope、grant type、签名算法以及其他提供方元数据。

核心端点

EndpointURLDescription
Authorization/realms/<realm>/protocol/openid-connect/auth发起用户认证。支持 response_type:code、id_token、token。
Token/realms/<realm>/protocol/openid-connect/token将授权码、刷新令牌或客户端凭据兑换为令牌。
UserInfo/realms/<realm>/protocol/openid-connect/userinfo返回关于已认证用户的声明。需要有效的访问令牌。
JWKS/realms/<realm>/protocol/openid-connect/certs返回用于验证令牌签名的公钥(JWK Set 格式)。
End Session (Logout)/realms/<realm>/protocol/openid-connect/logout终止用户的 SSO 会话。支持 id_token_hint 和 post_logout_redirect_uri。
Token Introspection/realms/<realm>/protocol/openid-connect/token/introspect返回令牌的激活/未激活状态及其声明。需要客户端认证。
Token Revocation/realms/<realm>/protocol/openid-connect/revoke撤销刷新令牌或访问令牌。需要客户端认证。

注册和管理端点

EndpointURLDescription
Dynamic Client Registration/realms/<realm>/clients-registrations/openid-connectOIDC 动态客户端注册端点。需要初始访问令牌或有效的 bearer token。
Client Registration (Keycloak format)/realms/<realm>/clients-registrations/default使用 Keycloak 客户端表示格式进行的 Keycloak 专用客户端注册。

设备和 Backchannel 端点

EndpointURLDescription
Device Authorization/realms/<realm>/protocol/openid-connect/auth/device为输入受限设备发起 OAuth 2.0 设备授权授予流程。
Backchannel Authentication (CIBA)/realms/<realm>/protocol/openid-connect/ext/ciba/auth发起 Client Initiated Backchannel Authentication。

SAML 端点

EndpointURLDescription
SAML Descriptor/realms/<realm>/protocol/saml/descriptor返回 IdP SAML 元数据文档(实体描述符)。
SAML SSO (Redirect)/realms/<realm>/protocol/samlSAML 单点登录端点(HTTP-Redirect 和 HTTP-POST 绑定)。

Admin REST API

EndpointURLDescription
Admin API Base/admin/realms/<realm>Keycloak Admin REST API 的基础 URL。参见 Admin REST API。

Token 端点认证方法

调用 token 端点时,客户端可使用以下方式进行认证:

MethodDescription
client_secret_post通过 POST 请求体参数发送 Client ID 和 secret
client_secret_basic通过 HTTP Basic Authentication 头发送 Client ID 和 secret
client_secret_jwt客户端使用通过 client secret(HMAC)签名的 JWT 进行认证
private_key_jwt客户端使用通过私钥(RSA/EC)签名的 JWT 进行认证
none不进行客户端认证(公共客户端,必须使用 PKCE)

支持的 Scope

ScopeClaims Included
openidsub(OIDC 必需)
profilename、family_name、given_name、preferred_username、locale
emailemail、email_verified
addressaddress
phonephone_number、phone_number_verified
rolesrealm_access.roles、resource_access.<client>.roles
microprofile-jwtgroups、upn
offline_access请求一个对离线访问有效的刷新令牌