metadata.adoc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. [[servlet-saml2login-metadata]]
  2. = Producing `<saml2:SPSSODescriptor>` Metadata
  3. You can publish a metadata endpoint by adding the `Saml2MetadataFilter` to the filter chain, as you'll see below:
  4. ====
  5. .Java
  6. [source,java,role="primary"]
  7. ----
  8. DefaultRelyingPartyRegistrationResolver relyingPartyRegistrationResolver =
  9. new DefaultRelyingPartyRegistrationResolver(this.relyingPartyRegistrationRepository);
  10. Saml2MetadataFilter filter = new Saml2MetadataFilter(
  11. relyingPartyRegistrationResolver,
  12. new OpenSamlMetadataResolver());
  13. http
  14. // ...
  15. .saml2Login(withDefaults())
  16. .addFilterBefore(filter, Saml2WebSsoAuthenticationFilter.class);
  17. ----
  18. .Kotlin
  19. [source,kotlin,role="secondary"]
  20. ----
  21. val relyingPartyRegistrationResolver: Converter<HttpServletRequest, RelyingPartyRegistration> =
  22. DefaultRelyingPartyRegistrationResolver(this.relyingPartyRegistrationRepository)
  23. val filter = Saml2MetadataFilter(
  24. relyingPartyRegistrationResolver,
  25. OpenSamlMetadataResolver()
  26. )
  27. http {
  28. //...
  29. saml2Login { }
  30. addFilterBefore<Saml2WebSsoAuthenticationFilter>(filter)
  31. }
  32. ----
  33. ====
  34. You can use this metadata endpoint to register your relying party with your asserting party.
  35. This is often as simple as finding the correct form field to supply the metadata endpoint.
  36. By default, the metadata endpoint is `+/saml2/service-provider-metadata/{registrationId}+`.
  37. You can change this by calling the `setRequestMatcher` method on the filter:
  38. ====
  39. .Java
  40. [source,java,role="primary"]
  41. ----
  42. filter.setRequestMatcher(new AntPathRequestMatcher("/saml2/metadata/{registrationId}", "GET"));
  43. ----
  44. .Kotlin
  45. [source,kotlin,role="secondary"]
  46. ----
  47. filter.setRequestMatcher(AntPathRequestMatcher("/saml2/metadata/{registrationId}", "GET"))
  48. ----
  49. ====
  50. Or, if you have registered a custom relying party registration resolver in the constructor, then you can specify a path without a `registrationId` hint, like so:
  51. ====
  52. .Java
  53. [source,java,role="primary"]
  54. ----
  55. filter.setRequestMatcher(new AntPathRequestMatcher("/saml2/metadata", "GET"));
  56. ----
  57. .Kotlin
  58. [source,kotlin,role="secondary"]
  59. ----
  60. filter.setRequestMatcher(AntPathRequestMatcher("/saml2/metadata", "GET"))
  61. ----
  62. ====