README.adoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. = SAML 2.0 Login & Logout Federation Sample using SAML Extension URLs
  2. This guide provides instructions on setting up the new Spring Security SAML 2.0 support using the endpoint URLs from the EOLd Spring Security SAML Extension.
  3. It differs from the `custom-urls` sample in that it is configured to have the registration id be the entity id for each asserting party, an important consideration when federating against hundreds of endpoints.
  4. This code uses `RelyingPartyRegistrations#collectionFromMetadata` to demonstrate how to copy this relying party's configuration across several arbitrary asserting party configurations returns from a single endpoint.
  5. See the https://github.com/spring-projects/spring-security/wiki/SAML-2.0-Migration-Guide[SAML 2.0 Migration Guide] for more details about the migration.
  6. == Key Changes
  7. === URL Forwarding Filter
  8. Instead of customizing the default Spring Security configuration, a new `Filter` has been created named `SamlExtensionUrlForwardingFilter`.
  9. This new filter is responsible to forward from the SAML Extension URLs to the new https://docs.spring.io/spring-security/reference/servlet/saml2/login/overview.html[Spring Security SAML 2.0 support URLs].
  10. Below is a table with the URLs that the Filter listen to (column 1) and forwards to (column 2).
  11. |===
  12. |SAML Extension URLs |Spring Security SAML 2.0 Support URLs |Description
  13. |`/saml/SSO`
  14. |`/login/saml2/sso/one`
  15. |The URL that processes a `<saml2:Response>` from the IdP
  16. |`/saml/login`
  17. |`/saml2/authenticate/one`
  18. |The URL that triggers a SAML 2.0 Login
  19. |`/saml/logout`
  20. |`/logout/saml2/slo`
  21. |The URL that trigger an SP's initiated SAML 2.0 Logout
  22. |`/saml/SingleLogout`
  23. |`/logout/saml2/slo`
  24. |The URL that processes a `<saml2:LogoutRequest>` from the IdP
  25. |`/saml/metadata`
  26. |`/saml2/service-provider-metadata/one`
  27. |The URL that generates the SP metadata
  28. |===
  29. Note that the `SamlExtensionUrlForwardingFilter` has an order of `-102`, this makes it be invoked before the `FilterChainProxy`.
  30. [source,java]
  31. ----
  32. @Component
  33. @Order(-102) // To run before FilterChainProxy
  34. public class SamlExtensionUrlForwardingFilter extends OncePerRequestFilter {
  35. // ...
  36. }
  37. ----
  38. === application.yml
  39. [source%linenums,yml]
  40. ----
  41. spring:
  42. security:
  43. filter:
  44. dispatcher-types: async, error, request, forward <1>
  45. saml2:
  46. relyingparty:
  47. registration:
  48. one:
  49. singlelogout:
  50. binding: POST
  51. url: "{baseUrl}/saml/logout" <2>
  52. responseUrl: "{baseUrl}/saml/SingleLogout" <3>
  53. acs:
  54. location: "{baseUrl}/saml/SSO" <4>
  55. assertingparty.metadata-uri: https://dev-05937739.okta.com/app/exk598vc9bHhwoTXM5d7/sso/saml/metadata
  56. ----
  57. ==== `RelyingPartyRegistration` properties
  58. The `RelyingPartyRegistration` properties should also be customized to match the values that were used by the SAML Extension (see <2>, <3> and <4> above).