Hi,
I have been able to set up SSO successfully in my application (SP) using pac4j with many different IdPs, but I noticed an issue when attempting to perform IdP initated SLO. The issue also occurred when using your spring-webmvc-pac4j sample application.
I attemped with Salesforce and Azure AD/Office and I had the same issue in both.
For some reason, in ADFS it seems to work.
So the issue is the following:
When the logout request is sent from the IdP to my app it doesn't contain the pac4j Session Cookie, thus, when pac4j attempts to destroy the session it simply can't.
In the code I'm referring to this method:
at org.pac4j.core.logout.handler.DefaultLogoutHandler.destroySessionFront(DefaultLogoutHandler.java:71)
at org.pac4j.saml.logout.impl.SAML2LogoutValidator.validateLogoutRequest(SAML2LogoutValidator.java:150)
at org.pac4j.saml.logout.impl.SAML2LogoutValidator.validate(SAML2LogoutValidator.java:81)
at org.pac4j.saml.profile.impl.AbstractSAML2MessageReceiver.receiveMessage(AbstractSAML2MessageReceiver.java:53)
This results in always showing the error:
"The user profiles (and session) can not be destroyed for the front channel logout because the provided key is not the same as the one linked to the current session"It seems to me that the issue is on the cookie not being present, I could be completly wrong though.
If I'm right, is it a failure on the IdP side for not storing the cookie on their side before redirecting to the SP?
Or this is how it is supposed to work and I should not be relying on cookies to perform IdP-initiated SLO?
I'll attach some screenshots of SAML tracer and pac4j logs that may be useful.
In this case I'm running your spring-webmvc-pac4j in localhost with an nginx server, so that I could provide valid URLs to the IdPs that I used instead of
http://localhost/.
I changed the code so that my Salesforce IdP is used instead of your Okta testpac4j account.
Obs: Central logout starting at the SP always works, because the SP destroys its session regardless of what happens after sending the logout request.
Screenshot 1: Cookie being set after performing SSO. User can access protected route after being redirected.
Screenshot 2:
SLO is trigeered by the IdP but no cookies are sent on the SAML Logout request.
Before sending a 200 response, the error (The user profiles (and session) can not be destroyed for the front channel logout because the provided key is not the same as the one linked to the current session) is shown on the webserver.
I assume a new session ID is sent back in the set-cookie header because there wasn't a session id in the first request to begin with?
Screenshot 3: Server Logs.
Thanks in advance!