private Map<String, Object> getDefaultRequestAttributes() { this.function.defaultRequest().accept(this.spec); verify(this.spec).attributes(this.attrs.capture()); this.attrs.getValue().accept(this.result); return this.result; }
@GetMapping("/foos/{id}") public Mono<Foo> getFooResource(@RegisteredOAuth2AuthorizedClient("custom") OAuth2AuthorizedClient client, @PathVariable final long id){ return webClient .get() .uri("http://localhost:8088/spring-security-oauth-resource/foos/{id}", id) .attributes(oauth2AuthorizedClient(client)) .retrieve() .bodyToMono(Foo.class); }
/** * Provides defaults for the {@link HttpServletRequest} and the {@link HttpServletResponse} using * {@link RequestContextHolder}. It also provides defaults for the {@link Authentication} using * {@link SecurityContextHolder}. It also can default the {@link OAuth2AuthorizedClient} using the * {@link #clientRegistrationId(String)} or the {@link #authentication(Authentication)}. * @return the {@link Consumer} to populate the attributes */ public Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest() { return spec -> { spec.attributes(attrs -> { populateDefaultRequestResponse(attrs); populateDefaultAuthentication(attrs); populateDefaultOAuth2AuthorizedClient(attrs); }); }; }
/** * Provides defaults for the {@link HttpServletRequest} and the {@link HttpServletResponse} using * {@link RequestContextHolder}. It also provides defaults for the {@link Authentication} using * {@link SecurityContextHolder}. It also can default the {@link OAuth2AuthorizedClient} using the * {@link #clientRegistrationId(String)} or the {@link #authentication(Authentication)}. * @return the {@link Consumer} to populate the attributes */ public Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest() { return spec -> { spec.attributes(attrs -> { populateDefaultRequestResponse(attrs); populateDefaultAuthentication(attrs); populateDefaultOAuth2AuthorizedClient(attrs); }); }; }