I have a secured micro service that is calling another secured micro service. Both services have service accounts in Keycloak. How can I configure the 1st service to automatically obtain access token from keycloak when calling the 2nd service? It's a simple service to service communication. Does the Quarkus Rest client have an API to do this? If not, how can I do that with the vert.x rest client?
Asked
Active
Viewed 2,390 times
4
-
In Spring Security that would be org.springframework.security.oauth2.client.OAuth2RestTemplate – overthetop Feb 20 '20 at 15:01
-
I thought that the token would be passed automatically to the rest client by microprofile definition. If that's not the case, then you should inject your token via @ClientHeaderParam(name = "Authorization", value = "{token}") in your rest client. – Serkan Feb 23 '20 at 16:15
-
1Yes @Serkan you can pass the token that way. I've end up using the vertx stuff because of the oauth2 providers and the ease of use for the web client. – overthetop Feb 24 '20 at 08:22
-
It seems like this is currently an open Quarkus issue: [Implement token propagation in the REST client](https://github.com/quarkusio/quarkus/issues/4214). You may want to keep an eye on it. – Steve C Feb 29 '20 at 01:22
1 Answers
3
I was able to make this work by extending the javax.ws.rs.client.ClientRequestFilter. Unfortunately I had to write my own OAuth2 logic in order to manage the access token between the requests. I hope that in the future Quarkus would provide an alternative to org.springframework.security.oauth2.client.OAuth2RestTemplate

overthetop
- 1,664
- 2
- 15
- 25