Skip to content

Commit cf17368

Browse files
filippomczoran-sinnema
authored andcommitted
revert: changes to create_api_user
1 parent 9f6296c commit cf17368

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

applications/accounts/scripts/create_api_user.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ PASSWORD=$(cat /opt/cloudharness/resources/auth/api_user_password)
77
echo "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
1516
fi
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

0 commit comments

Comments
 (0)