#OIDC 端点参考
Keycloak 为每个 Realm 提供一组标准的 OpenID Connect 和 OAuth 2.0 端点。所有端点都可通过 OIDC 发现文档进行发现。
#发现端点
GET https://<keycloak-host>/realms/<realm>/.well-known/openid-configuration返回一个 JSON 文档,列出所有可用端点、受支持的 scope、grant type、签名算法以及其他提供方元数据。
#核心端点
| Endpoint | URL | Description |
|---|---|---|
| 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 | 撤销刷新令牌或访问令牌。需要客户端认证。 |
#注册和管理端点
| Endpoint | URL | Description |
|---|---|---|
| Dynamic Client Registration | /realms/<realm>/clients-registrations/openid-connect | OIDC 动态客户端注册端点。需要初始访问令牌或有效的 bearer token。 |
| Client Registration (Keycloak format) | /realms/<realm>/clients-registrations/default | 使用 Keycloak 客户端表示格式进行的 Keycloak 专用客户端注册。 |
#设备和 Backchannel 端点
| Endpoint | URL | Description |
|---|---|---|
| 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 端点
| Endpoint | URL | Description |
|---|---|---|
| SAML Descriptor | /realms/<realm>/protocol/saml/descriptor | 返回 IdP SAML 元数据文档(实体描述符)。 |
| SAML SSO (Redirect) | /realms/<realm>/protocol/saml | SAML 单点登录端点(HTTP-Redirect 和 HTTP-POST 绑定)。 |
#Admin REST API
| Endpoint | URL | Description |
|---|---|---|
| Admin API Base | /admin/realms/<realm> | Keycloak Admin REST API 的基础 URL。参见 Admin REST API。 |
#Token 端点认证方法
调用 token 端点时,客户端可使用以下方式进行认证:
| Method | Description |
|---|---|
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
| Scope | Claims Included |
|---|---|
openid | sub(OIDC 必需) |
profile | name、family_name、given_name、preferred_username、locale |
email | email、email_verified |
address | address |
phone | phone_number、phone_number_verified |
roles | realm_access.roles、resource_access.<client>.roles |
microprofile-jwt | groups、upn |
offline_access | 请求一个对离线访问有效的刷新令牌 |