protected-resource-metadata.adoc 1.5 KB

12345678910111213141516171819202122232425262728
  1. [[oauth2resourceserver-protected-resource-metadata]]
  2. = OAuth 2.0 Protected Resource Metadata
  3. `OAuth2ResourceServerConfigurer.ProtectedResourceMetadataConfigurer` provides the ability to customize the https://www.rfc-editor.org/rfc/rfc9728.html#section-3[OAuth 2.0 Protected Resource Metadata endpoint].
  4. It defines an extension point that lets you customize the https://www.rfc-editor.org/rfc/rfc9728.html#section-3.2[OAuth 2.0 Protected Resource Metadata response].
  5. `OAuth2ResourceServerConfigurer.ProtectedResourceMetadataConfigurer` provides the following configuration option:
  6. [source,java]
  7. ----
  8. @Bean
  9. public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
  10. http
  11. .oauth2ResourceServer((resourceServer) ->
  12. resourceServer
  13. .protectedResourceMetadata(protectedResourceMetadata ->
  14. protectedResourceMetadata
  15. .protectedResourceMetadataCustomizer(protectedResourceMetadataCustomizer) <1>
  16. )
  17. );
  18. return http.build();
  19. }
  20. ----
  21. <1> `protectedResourceMetadataCustomizer()`: The `Consumer` providing access to the `OAuth2ProtectedResourceMetadata.Builder` allowing the ability to customize the claims of the Resource Server's configuration.
  22. `OAuth2ResourceServerConfigurer.ProtectedResourceMetadataConfigurer` configures the `OAuth2ProtectedResourceMetadataFilter` and registers it with the Resource Server `SecurityFilterChain` `@Bean`.
  23. `OAuth2ProtectedResourceMetadataFilter` is the `Filter` that returns the https://www.rfc-editor.org/rfc/rfc9728.html#section-3.2[OAuth2ProtectedResourceMetadata response].