Hello, I would like some advice on how to import user profile schema automatically. I know there is an export/import option in the admin-panel, but I rather want this to be setup automatically.
I have tried to update the config-piece-0
and config-pieces-count
values directly in the database, while having the declarative-user-profile
active. But this seem to not update the UserProfile page.
It seemed like a straightforward way to setup keycloak this way. I run a bash script inside a docker container like this:
JSON=`cat /opt/keycloak/data/import/attributes.json`
/opt/keycloak/bin/kc.sh import --file /opt/keycloak/data/import/bikefolder-realm.json
COMPONENT_ID=$(mysql --host="mysql-kc" --user="keycloak_user" --password="keycloak_password" --database="keycloak_db" -ss --execute="SELECT ID FROM COMPONENT WHERE PROVIDER_ID='declarative-user-profile';")
UUID=`uuidgen`
mysql --host="mysql-kc" --user="keycloak_user" --password="keycloak_password" --database="keycloak_db" --execute="INSERT INTO COMPONENT_CONFIG (ID, COMPONENT_ID, NAME, VALUE) VALUES ('$UUID', 'c', 'config-piece-0', '$JSON');"
UUID=`uuidgen`
mysql --host="mysql-kc" --user="keycloak_user" --password="keycloak_password" --database="keycloak_db" --execute="INSERT INTO COMPONENT_CONFIG (ID, COMPONENT_ID, NAME, VALUE) VALUES ('$UUID', '$COMPONENT_ID', 'config-pieces-count', 1);"
Is there other ways to do this?