I have a microservice in charge of generating JWT with different information.
For some reason, the jwt is injected by the Spring gateway with a custom filter.
the problem is, that the filter can't block before to have the response.
So the filters are chained before that the jwt can be injected in the request.
Any idea to resolve this problem?
See my filter:
[...]
@Component
public class AddJwtFilter implements GlobalFilter {
[...]
Mono<String> response = webClient.get().uri("https://localhost:9001/security/generatejwt/{accessToken}", accessToken).retrieve().bodyToMono(String.class);
response.subscribe(System.out::println);
System.out.println("I return the chain");
return chain.filter(exchange);
}
}
The System.out::println is not the real treatment that i want, it justs to check when the response is completed. The Request is correct, and "println" gives me the response expected.
Thanks a lot for your responses.
Like said in the comments you need to chain everything.
@Component
public class AddJwtFilter implements GlobalFilter {
return webClient.get()
.uri("https://localhost:9001/security/generatejwt/{accessToken}",
accessToken)
.retrieve()
.bodyToMono(String.class).flatMap(response -> {
System.out.println(response);
return chain.filter(exchange);
});
}