【发布时间】:2019-02-24 13:58:40
【问题描述】:
我在 Keycloak Server 4.2.1 中使用 saml 协议注销时遇到问题。 Keycloak 旁边是 Wildfly 9 服务器。在 Wildfly 服务器那里 是部署的多个 .war 文件。它们是 JEE7 的 JSF 应用程序。
我像这样配置了 saml 适配器 (keycloak-saml.xml)。类似于文档 (https://www.keycloak.org/docs/latest/securing_apps/index.html#_saml-general-config)
<keycloak-saml-adapter>
<SP entityID="amp"
sslPolicy="EXTERNAL"
logoutPage="logout.jsp">
<Keys>
<Key signing="true">
<PrivateKeyPem>
...CLIENT PRIVATE KEY...
</PrivateKeyPem>
<CertificatePem>
...CLIENT CERTIFICATE ...
</CertificatePem>
</Key>
</Keys>
<PrincipalNameMapping policy="FROM_ATTRIBUTE"/>
<IDP entityID="idp"
signatureAlgorithm="RSA_SHA256"
signatureCanonicalizationMethod="http://www.w3.org/2001/10/xml-exc-c14n#">
<SingleSignOnService signRequest="true"
validateResponseSignature="true"
requestBinding="POST"
bindingUrl="http://localhost:8080/auth/realms/My-Realm/protocol/saml"/>
<SingleLogoutService signRequest="true"
signResponse="true"
validateRequestSignature="true"
validateResponseSignature="true"
requestBinding="POST"
responseBinding="POST"
postBindingUrl="http://localhost:8080/auth/realms/My-Realm/protocol/saml"
redirectBindingUrl="http://localhost:8080/auth/realms/My-Realm/protocol/saml"/>
<Keys>
<Key signing="true">
<CertificatePem>
... REALM CERTIFICATE ...
</CertificatePem>
</Key>
</Keys>
</IDP>
</SP>
</keycloak-saml-adapter>
当我单击“注销按钮”时,应用程序调用 下面的代码使 Wildfly 服务器使会话无效。
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).logout();
((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false)).invalidate();
我检查了它及其工作,应用程序使会话无效。
在那之后,我必须告诉 keycloak 服务器他也应该使这个会话无效。 我必须调用哪个 URL?
FacesContext.getCurrentInstance().getExternalContext().redirect(" ???? ");
在迁移到 Keycloak Server 4.2.1 之前,我运行的是旧版本 1.8.1。 使用 1.8.1 服务器,我调用了 URL
“http://localhost:8080/auth/realms/My-Realm/tokens/logout?redirect_uri=http://localhost:8180/amp”。
但这已经不起作用了。
我已经测试了多个 URL,但它们都不起作用。我查了最新的 文档https://www.keycloak.org/docs/latest/securing_apps/index.html#logout-2 并且参数 GLO=true 也不起作用。 我还尝试配置“Logout Service POST Binding URL”和“Logout Service Redirect Binding URL” 用于 keycloak 管理控制台中的客户端。
我是否错过了 keycloak 的代码或管理控制台中的某些内容? 我必须在 keycloak 4.2.1 中调用特定的 url 吗?
如果您需要更多信息,请告诉我。
感谢您的帮助。
亲切的问候。
【问题讨论】:
-
您找到解决方案了吗?我陷入了类似的境地。
-
嘿,我正在调用全局注销 url。我为keycloak服务器中的客户端配置了“注销服务POST绑定URL”和“注销服务重定向绑定URL”地址:localhost:8180/MY_APP_NAME。在我的代码中,我正在调用:
java FacesContext context = getCurrentInstance(); ((HttpServletRequest) context.getExternalContext().getRequest()).logout()((HttpSession) context.getExternalContext().getSession(false)).invalidate(); context.getExternalContext().redirect("http://localhost:8180/MY_APP_NAME/saml/logout?GLO=true");抱歉格式太糟糕了..