File tree Expand file tree Collapse file tree
applications/accounts/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,13 +7,17 @@ PASSWORD=$(cat /opt/cloudharness/resources/auth/api_user_password)
77echo " Checking if API user exists..."
88
99# Check if user already exists
10- if /opt/keycloak/bin/kcadm.sh get users -q " username=$USERNAME " | grep -v " $USERNAME " ; then
11- # create the user and reload keycloak
12- echo " Creating API user $USERNAME "
13- /opt/keycloak/bin/kcadm.sh create users -s " username=$USERNAME " -s enabled=True
14- echo " API user created successfully"
10+ if /opt/keycloak/bin/kcadm.sh get users -q " username=$USERNAME " | grep -q " $USERNAME " ; then
11+ echo " ERROR: API user $USERNAME already exists, but password is out of sync. You may need to reset it manually."
12+ # /opt/keycloak/bin/kcadm.sh set-password --username "$USERNAME" --new-password "$PASSWORD"
13+ # Removed automatic password reset as that would only work if the main admin password is unchanged from the default password
14+ # That would create the false impression that the password is reset successfully when in fact it has not on production systems
15+ exit 0
1516fi
1617
17- echo Setting API user password
18+ echo " Creating API user $USERNAME "
19+ set -e
20+ # create the user and reload keycloak
21+ /opt/keycloak/bin/kcadm.sh create users -s " username=$USERNAME " -s enabled=True
1822/opt/keycloak/bin/kcadm.sh set-password --username " $USERNAME " --new-password " $PASSWORD "
1923/opt/keycloak/bin/kcadm.sh add-roles --uusername " $USERNAME " --rolename admin
You can’t perform that action at this time.
0 commit comments