I have a problem with SSO add-on. We configure Azure AD as SAML IP and all works fine for first time login.
But when we try to login second time (the IP session is still valid) we are getting error:
java.lang.RuntimeException: Failed to determinate SAML connection
at com.haulmont.addon.saml.saml.internal.impl.SamlConnectionContextProviderImpl.populateConnection(SamlConnectionContextProviderImpl.java:157) ~[na:na]
at com.haulmont.addon.saml.saml.internal.impl.SamlConnectionContextProviderImpl.getLocalEntity(SamlConnectionContextProviderImpl.java:109) ~[na:na]
at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:84) ~[na:na]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212) ~[na:na]
cuba version: 7.2.5
com.haulmont.addon.saml:saml-addon-global:0.4.2
The problem comes from the recent security update in Chrome regarding the handling of the SameSite attribute in cookies.
The reason is that JSESSIONID cookie doesnât have attribute SameSite specified. Chrome defaults it to SameSite=Lax and then blocks it because the request was made from a different site (IDP). It leads to invalidating the current session and losing the tenant attribute which causes the error above.
At the moment we are thinking of some workaround for SAML add-on, but you can try overcoming this issue by using SameSite=None; Secure cookie policy.
Hi @shalyganov, thanks for your guidance on this issue. We have tried to set the SameSite attribute ourselves but it doesnât seem to be setting correctly for us. What we have tried is the following right before initiating the request to our IdP. Should we be trying to modify the session at a different entry point perhaps?
Actually, this cookie setting is configured on the servlet container side. For example, in case of Tomcat it can be achieved by declaring the CookieProcessor as described here. Unfortunately, current version of Cuba plugin depends on the Tomcat 9.0.27, in which this approach doesnât work because of the bug. We are planning to update the tomcat version in the next bugfix release, which is expected in early November. Nevertheless, you can build a WAR and deploy it to the more recent version of Tomcat.
In case of UberJar, Jetty version also needs to be updated.
The above worked for me. It has resolved the issue where logging into AD using SAML didnât always work. Fix for me is to use tomcat 9.0.37 with the following line added to /opt/tomcat/webapps/ROOT/META-INF/context.xml , enclosed in <>
CookieProcessor sameSiteCookies=ânoneâ Thank you @shalyganov
It actually means that CUBA framework version from 7.2.9 should be used (ext.cubaVersion property in build.gradle file). Corresponding CUBA gradle plugin version will be applied automatically due to the following block:
When using CUBA > 7.2.9, UberJar will be generated using Jetty version that supports same-site cookie. Follow the step I described in the previous post for the cookie config to take effect.