Describe the bug When clickjacking prevention is enabled, it is impossible to redirect SAML2 request to IdP.
To Reproduce
1. Enable clickjacking prevention.
2. Define SAML2 IdP provider as Okta in spring boot application
3. Try to run the authentication flow by pointing the browser to the URL: https://
After investigation it looks like the issue is related to metadata returned from Okta:
"
and the issue is in org.springframework.security.saml2.provider.service.web.Saml2WebSsoAuthenticationRequestFilter that produces this page as part of this method: private String createSamlPostRequestFormData(Saml2PostAuthenticationRequest authenticationRequest)
Expected behavior Redirect to IdP login page should happen without issues described above.
Sample I cant provide our enterprise application but the issue can be also reproduced in demo application here: https://github.com/oktadev/okta-spring-boot-saml-example if changing the domain and enable the clickjacking prevention
Comment From: marcusdacoregio
Hi, @evgusha80.
If you take a look at the class that you mentioned, you can see that it includes the required Content-Security-Policy meta tag in the generated HTML. It might be possible that the tag is being replaced in your production environment? The hash even matches the hash that the error message provides.
Comment From: evgusha80
Hello @marcusdacoregio , Thanks for the quick reply and pointing to the root cause. I've applied the suggestion in our production and the fix is working fine You can resolve the ticket. Thanks, Evgeny