README.adoc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. == Run the Sample
  7. === Install Docker
  8. This sample requires Docker to run a local IdP.
  9. As an alternative, you can point the sample at your own IdP by changing the `application.yml` here:
  10. [source,java]
  11. ----
  12. spring:
  13. security:
  14. saml2:
  15. relyingparty:
  16. registration:
  17. one:
  18. assertingparty.metadata-uri: {your-idp-metadata-endpoint}
  19. // ...
  20. two:
  21. assertingparty.metadata-uri: {your-idp-metadata-endpoint}
  22. ----
  23. === Start up the Sample Boot Application
  24. ```
  25. ./gradlew :servlet:spring-boot:java:saml2:saml-extension-federation:bootRun
  26. ```
  27. === Open a Browser
  28. http://localhost:8080/
  29. You will be redirected to the SimpleSAMLPHP instance.
  30. === Type in your credentials
  31. ```
  32. User: user1
  33. Password: user1pass
  34. ```
  35. == Key Changes
  36. === URL Forwarding Filter
  37. Instead of customizing the default Spring Security configuration, a new `Filter` has been created named `SamlExtensionUrlForwardingFilter`.
  38. 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].
  39. Below is a table with the URLs that the Filter listen to (column 1) and forwards to (column 2).
  40. |===
  41. |SAML Extension URLs |Spring Security SAML 2.0 Support URLs |Description
  42. |`/saml/SSO`
  43. |`/login/saml2/sso/one`
  44. |The URL that processes a `<saml2:Response>` from the IdP
  45. |`/saml/login`
  46. |`/saml2/authenticate/one`
  47. |The URL that triggers a SAML 2.0 Login
  48. |`/saml/logout`
  49. |`/logout/saml2/slo`
  50. |The URL that trigger an SP's initiated SAML 2.0 Logout
  51. |`/saml/SingleLogout`
  52. |`/logout/saml2/slo`
  53. |The URL that processes a `<saml2:LogoutRequest>` from the IdP
  54. |`/saml/metadata`
  55. |`/saml2/service-provider-metadata/one`
  56. |The URL that generates the SP metadata
  57. |===
  58. Note that the `SamlExtensionUrlForwardingFilter` has an order of `-102`, this makes it be invoked before the `FilterChainProxy`.
  59. [source,java]
  60. ----
  61. @Component
  62. @Order(-102) // To run before FilterChainProxy
  63. public class SamlExtensionUrlForwardingFilter extends OncePerRequestFilter {
  64. // ...
  65. }
  66. ----
  67. === `RelyingPartyMetadata` configuration component
  68. The `RelyingPartyRegistration` properties are customized to match the values that were used by the SAML Extension.
  69. These reside in `RelyingPartyMetadata`.