问题描述
我想问一下是否有办法通过单个 http 请求从 keycloak
注销.
I wanted to ask if there is a way to logout from keycloak
via a single http request.
我已经尝试 POST /protocol/openid-connect/logout
或 /tokens/logout
,但结果始终是 ORIGIN-Problem.
I already tried to POST /protocol/openid-connect/logout
or /tokens/logout
, but the result is always a ORIGIN-Problem.
但是调用 ORIGIN 是在 keycloak 中配置的,并且请求登录是有效的.
But the calling ORIGIN is configured in keycloak and the login with a request works.
这里有没有机会在不重定向或打开另一个窗口的情况下注销?
Any chance here to logout without redirecting or open another window?
最好的问候和感谢!:)
Best regards and thanks! :)
推荐答案
来自 官方文档:
您可以通过多种方式退出 Web 应用程序.对于 Java EEservlet 容器,您可以调用 HttpServletRequest.logout()
.
对于其他浏览器应用程序,您可以将浏览器重定向到http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri
,如果您与浏览器进行 SSO 会话,它会将您注销.
For other browser applications, you can redirect the browser to http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri
, which logs you out if you have an SSO session with your browser.
要获取应用的确切 URL(主机、领域和 redirect_uri 配置):
To get the exact URL of the app (host, realm and redirect_uri configuration):
- 登录您的 Keycloak 用户帐户
- 打开浏览器的开发者控制台
- 执行注销操作
- 记下用于请求注销的 URL
- 使用与您的应用程序相同的 URL 来执行注销
这篇关于Keycloak 注销请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!