1
votes

I try to use keycloak as the authentication service in my design. In my case, when the keycloak starts, I need one more realm besides default master realm. Assuming the new agency is called "demo". So it means when keycloak starts, it should have two realms (master and demo).

In addtion, in the realm demo, I need to configure the default client "admin-cli" to enable "Full Scope Allowed". Also need to add some buildin mapper to this client.

In this case, I wonder whether I can use something like initialization file which keycloak can load when starting ?

Or I need to use keycloak client APIs to do this operations (e.g., Java keycloak admin client)?

Thanks in advance.

1

1 Answers

3
votes

You can try the following:

  • Create the Realm;
  • Set all the options that you want;
  • Go to Manage > Export;
  • Switch Export groups and roles to ON;
  • Switch Export clients to ON;
  • Export.

enter image description here

That will export a .json file with the configurations.

Then you can tested it be deleting your Demo Realm and:

  • Go to Add Realm;
  • Chose the .json file that was exported;
  • Click Create.

enter image description here

Check if the configurations that you have changed are still presented on the Demo Realm, if there are then it means that you can use this file to import the Realm from. Otherwise, for the options that were not persistent you will have to create them via the Admin Rest API.