I’ve implemented a custom UserStorageProvider SPI and can successfully get a connection to an external database by defining the necessary parameters in keycloak/conf/quarkus.properties and then using the following code in the SPI to get access to an EntityManager.
keycloakSession.getProvider(JpaConnectionProvider.class, "my-datasource").getEntityManager();
This works great. However, I’d rather have the connection details be provided as configuration properties in the SPI. As in when the User Federation SPI is installed the user will type in the database connection details. I also have this working and can access the entered properties in my custom SPI.
What is the recommeded approach to creating an EntityManager in a SPI? I’ve seen an example here:
Is this the recommended approach or is there a better way?