我在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();
我检查了它并正常工作,该应用程序使会话无效。
现在,在那之后,我必须告诉密钥隐藏服务器他也应该使此会话无效。 我必须呼叫哪个网址?
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也不起作用。 我还尝试配置“注销服务POST绑定URL”和“注销服务重定向绑定URL” 在密钥斗篷管理控制台中访问客户端。
我是否错过了代码或Keycloak的管理控制台中的某些内容? 我必须在密钥斗篷4.2.1中调用特定的网址吗?
如果您需要更多信息,请告诉我。
感谢您的帮助。
亲切的问候。
答案 0 :(得分:0)
Keycloak提供了一个SAML终结点,即“ https:// {host} / auth / realms / {realm} / protocol / saml ”,您必须向该终结点发送SAML注销请求。在客户端SAML配置中,您要么必须设置指向应用程序的SAML端点的“主SAML处理URL”,要么如果您有一个特殊的SAML端点用于“单个注销”,则必须显式配置“注销服务重定向绑定URL”。您的应用程序。