KeycloakOidcConfiguration load during application start and load values from database

42 views Asked by At

I would like to load my Keycloak Settings dynamically from my database. I would like to do this:

  • Start my application
  • Load from my database required information for the KeycloakOidcConfiguration Object
  • Set the values which I got from my database to the KeycloakOidcConfiguration.

I tried to load it during App Start like this:

InputStream inputStream = getClass().getResourceAsStream("/shiro-web.ini");
Ini ini = new Ini();
ini.load(inputStream);
ini.setSectionProperty("main", "oidcConfig.realm", keycloakApplicationProvider.getRealm());

But this seems not working, I got this error message:

Caused by: org.pac4j.core.exception.TechnicalException: realm cannot be blank

In my shiro.ini I have this config:

#Keycloack
oidcConfig = org.pac4j.oidc.config.KeycloakOidcConfiguration

My question would be: how can I get the current KeycloakOidcConfiguration, which is using from Pac4j / Shiro? It seems for me at the moment I change (set) the wrong KeycloakOidcConfiguration.

Any ideas?

1

There are 1 answers

3
jleleu On

To load the Keycloak settings dynamically from your database, you need to create a CustomOidcClient and a CustomOidcConfiguration which initializes itself from the database.