Java Keycloak 注销请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37108782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Keycloak Logout Request
提问by Stack
I wanted to ask if there is a way to logout from keycloak
via a single http request.
我想问一下是否有办法keycloak
通过单个 http 请求注销。
I already tried to POST /protocol/openid-connect/logout
or /tokens/logout
, but the result is always a ORIGIN-Problem.
我已经尝试 POST/protocol/openid-connect/logout
或/tokens/logout
,但结果始终是 ORIGIN-Problem。
But the calling ORIGIN is configured in keycloak and the login with a request works.
但是调用 ORIGIN 是在 keycloak 中配置的,并且使用请求登录是有效的。
Any chance here to logout without redirecting or open another window?
这里有机会在不重定向或打开另一个窗口的情况下注销吗?
Best regards and thanks! :)
最好的问候和感谢!:)
回答by aName
From the official documentation:
从官方文档:
You can log out of a web application in multiple ways. For Java EE servlet containers, you can call
HttpServletRequest.logout()
.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.
您可以通过多种方式注销 Web 应用程序。对于 Java EE servlet 容器,您可以调用
HttpServletRequest.logout()
.对于其他浏览器应用程序,您可以将浏览器重定向到
http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri
,如果您与浏览器进行 SSO 会话,这会将您注销。
To get the exact URL of the app (host, realm and redirect_uri configuration):
要获取应用程序的确切 URL(主机、领域和 redirect_uri 配置):
- Log in to your Keycloak user account
- Open up the developer console of the browser
- Perform the logout operation
- Note down the URL that was used to request for logout
- Use the same URL from your application to perform the logout
- 登录您的 Keycloak 用户帐户
- 打开浏览器的开发者控制台
- 执行注销操作
- 记下用于请求注销的 URL
- 使用与您的应用程序相同的 URL 来执行注销