saml2.adoc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. = SAML 2.0 Migrations
  2. == Expect `<saml2:LogoutResponse>` When `<saml2:LogoutRequest>` Validation Fails
  3. SAML identity providers expect service providers to return an error `<saml2:LogoutResponse>` if it fails to process the `<saml2:LogoutRequest>`.
  4. Past versions of Spring Security returned a 401 in some cases, breaking the chain of logout requests and responses from each relying party.
  5. In Spring Security 7, this behavior is repaired, and you need do nothing.
  6. However, if this gives you trouble, you can revert back to the old behavior by publishing a `Saml2LogoutRequestResolver` that returns `null` when an error `<saml2:LogoutRequest>` is needed.
  7. You can create a delegate like this one:
  8. [tabs]
  9. ======
  10. Java::
  11. +
  12. [source,java,role="primary"]
  13. ----
  14. @Bean
  15. Saml2LogoutResponseResolver logoutResponseResolver(RelyingPartyRegistrationRepository registrations) {
  16. OpenSaml5LogoutResponseResolver delegate = new OpenSaml5LogoutResponseResolver(registrations);
  17. return new Saml2LogoutResponseResolver() {
  18. @Override
  19. public void resolve(HttpServletRequest request, Authentication authentication) {
  20. delegate.resolve(request, authentication);
  21. }
  22. @Override
  23. public void resolve(HttpServletRequest request, Authentication authentication, Saml2AuthenticationException error) {
  24. return null;
  25. }
  26. };
  27. }
  28. ----
  29. Kotlin::
  30. +
  31. [source,kotlin,role="secondary"]
  32. ----
  33. @Bean
  34. fun logoutResponseResolver(registrations: RelyingPartyRegistrationRepository?): Saml2LogoutResponseResolver {
  35. val delegate = OpenSaml5LogoutResponseResolver(registrations)
  36. return object : Saml2LogoutResponseResolver() {
  37. override fun resolve(request: HttpServletRequest?, authentication: Authentication?) {
  38. delegate.resolve(request, authentication)
  39. }
  40. override fun resolve(request: HttpServletRequest?, authentication: Authentication?, error: Saml2AuthenticationException?) {
  41. return null
  42. }
  43. }
  44. }
  45. ----
  46. ======