调用 Keycloak 的 end_session_enddpoint 的正确方法是什么

What is the proper way to invoke Keycloak's end_session_enddpoint

环境:Keycloak 12.0.4

我们计划允许各种受 OpenIDC 保护的应用程序使用 Keycloak 的 end_session_endpoint 启动“单点退出”。在我们的例子中,我们想提供我们自己的 URL 应用程序在他们想要注销时会点击。 URL 将以编程方式调用 end_session_endpoint 或简单地将用户的浏览器重定向到该端点。

到目前为止,我看到的 Keycloak 文档和示例在如何调用此端点方面有些混乱。例如,我是否需要添加一个以 id token 作为值的查询参数? (例如,我注意到 mod_auth_openidc 包含一个 id_token_hint 查询参数。)我假设此调用必须经过身份验证,所以我是否将客户端 id/secret 作为凭据包含在内?

谢谢!

您有标准的调用 RP 发起的注销的方法: https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout

An RP requests that the OP log out the End-User by redirecting the End-User's User Agent to the OP's Logout Endpoint.

这是一个重定向,而不是 API 调用,因为您很可能还想删除 IDP 会话(在您的情况下使用的 Keycloak 域上的 cookie)。

这是来自 keycloak-user 组的一些附加信息,我认为这些信息完全回答了这个问题:

You can look at https://openid.net/specs/openid-connect-session-1_0-17.html#RPLogout. From our implementation, we rely on either cookies or the id_token_hint to identify the user and logout sessions. So you don't necessarily need to send id_token_hint if cookies are sent when redirecting the user from your application to Keycloak. You can also send a state param to match if the logout action sent to your application originated from a valid logout request.

Note, however, that we don't force the id_token_hint and do not ask the user for confirmation, as per spec. But there are discussions to introduce a consent page.

In regards to logout, messages are sent to clients through the backchannel.

编辑:这是实际的(最新的)RP 启动的注销规范:https://openid.net/specs/openid-connect-rpinitiated-1_0.html