saml2.adoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. = Saml 2.0 Migrations
  2. == Continue Filter Chain When No Relying Party Found
  3. In Spring Security 6, `Saml2WebSsoAuthenticationFilter` throws an exception when the request URI matches, but no relying party registration is found.
  4. There are a number of cases when an application would not consider this an error situation.
  5. For example, this filter doesn't know how the `AuthorizationFilter` will respond to a missing relying party.
  6. In some cases it may be allowable.
  7. In other cases, you may want your `AuthenticationEntryPoint` to be invoked, which would happen if this filter were to allow the request to continue to the `AuthorizationFilter`.
  8. To improve this filter's flexibility, in Spring Security 7 it will continue the filter chain when there is no relying party registration found instead of throwing an exception.
  9. For many applications, the only notable change will be that your `authenticationEntryPoint` will be invoked if the relying party registration cannot be found.
  10. When you have only one asserting party, this means by default a new authentication request will be built and sent back to the asserting party, which may cause a "Too Many Redirects" loop.
  11. To see if you are affected in this way, you can prepare for this change in 6 by setting the following property in `Saml2WebSsoAuthenticationFilter`:
  12. [tabs]
  13. ======
  14. Java::
  15. +
  16. [source,java,role="primary"]
  17. ----
  18. http
  19. .saml2Login((saml2) -> saml2
  20. .withObjectPostProcessor(new ObjectPostProcessor<Saml2WebSsoAuhenticaionFilter>() {
  21. @Override
  22. public Saml2WebSsoAuthenticationFilter postProcess(Saml2WebSsoAuthenticationFilter filter) {
  23. filter.setContinueChainWhenNoRelyingPartyRegistrationFound(true);
  24. return filter;
  25. }
  26. })
  27. )
  28. ----
  29. Kotlin::
  30. +
  31. [source,kotlin,role="secondary"]
  32. ----
  33. http {
  34. saml2Login { }
  35. withObjectPostProcessor(
  36. object : ObjectPostProcessor<Saml2WebSsoAuhenticaionFilter?>() {
  37. override fun postProcess(filter: Saml2WebSsoAuthenticationFilter): Saml2WebSsoAuthenticationFilter {
  38. filter.setContinueChainWhenNoRelyingPartyRegistrationFound(true)
  39. return filter
  40. }
  41. })
  42. }
  43. ----
  44. Xml::
  45. +
  46. [source,xml,role="secondary"]
  47. ----
  48. <b:bean id="saml2PostProcessor" class="org.example.MySaml2WebSsoAuthenticationFilterBeanPostProcessor"/>
  49. ----
  50. ======