Keycloak 17: developing SPI with RestClient dependency

Hi
I’ve developed a SPI that implements UserStorageProvider.
This provider uses the RestClient to connect an external service. Deploying the SPI on the new version (17) I got an error with only the RestClient class name as message. It seems that Keycloak didn’t find the implementation of the RestClient.
Looking at the logs I saw that quarkus starts without the features quarkus-rest-client and quarkus-rest-client-jackson.
Which is the best way to add this dependencies?
Thanks
ps
I tried with either resteasy RestClient either microprofile RestClient

As Keycloak 17 doesn‘t use RestEasyClient, it‘s not bundled anymore. Before, with Wildfly, there was a whole bloated application server which had more modules than Keycloak needed. With Quarkus, only the libs which are needed by Keycloak are contained.

You can deploy your custom libraries together with your custom extension to the /providers folder of Keycloak. But be careful, the resteasy version in the pom‘s are still on 3.x, while at runtime they are currently 4.7.5.Final!

Alternatively, you can rewrite your extension to use Keycloak‘s SimpleHttp class, which provides some simple to use convenience methods for all HTTP verbs. Going this way, you don‘t need additional libs.

I’ve added this libraries, that are the dependecies of resteasy rest client 4.75, and that are missing in the keycloak lib

quarkus-rest-client-jackson
quarkus-rest-client
quarkus-apache-httpclient
quarkus-rest-client-config
microprofile-rest-client-api
resteasy-client-microprofile
resteasy-client-microprofile-base
resteasy-client,resteasy-client-api
resteasy-cdi
httpasyncclient
httpcore-nio

But I got this error
ERROR: RESTEASY010615: Unable to obtain ResteasyCdiExtension instance.

After many attempts I decided to proceed with the second option, reimplementing my SPI using SimpleHttp class

1 Like