I have managed to set up a Keycloak server embedded in a Spring Boot Application successfully, following this tutorial: Keycloak Embedded in a Spring Boot Application in order to avoid setting it up manually.
Since I am dealing with an old implementation that already has it’s own DB, I decided to use Keycloak’s User Storage SPI to connect to an external postgresql DB and use this for authentication instead of Keycloak DB.
To do this, I followed the tutorial on Keycloak documentation, but it envolves a standalone Keycloak server, creating a .jar with the custom provider and injecting it to <pathToKeycloak>/standalone/deployments/ .
I have created an implementation that works with a standalone Keycloak server, but now I want to include it to the embedded one. Is it possible to use a Keycloak server Embedded in a Spring Boot Application and also have an embedded custom User Storage Provider, to avoid setting up manually?
A little late, but since I got to the same topic and found a solution:
Yes, it is possible. You just have to “merge” the spi code with the embedded Keycloak code. For example,
following the tutorial, you will have the following files: