Reset Management UI Local User Password

Use this procedure to reset the password of a local user (for example, scality) when no administrator can log in to the management UI.

This procedure applies to local users only. The password of an LDAP user is managed in the LDAP directory.

The new password is temporary: the user must set a permanent password at the next login to the management UI.

Note

If an administrator can still log in to the management UI, use Configure a User Temporary Password instead.

Prerequisites

  • You can log in to a ARTESCA node as the artesca-os user.

  • kubectl, jq, and curl are installed.

Procedure

Note

Run all commands in the same shell session. Each step reuses the variables declared in the previous steps.

  1. Retrieve the URL for the management UI.

    [artesca-os@bootstrap ~]$
    
    URL=$(sudo salt-call metalk8s_network.get_control_plane_ingress_endpoint --out=json | jq -cr '.local')
    
  2. Retrieve the Identity Provider administrator password.

    [artesca-os@bootstrap ~]$
    
    KC_ADMIN_PASSWORD=$(sudo kubectl --kubeconfig=/etc/kubernetes/admin.conf \
        get secret artesca-kc-initial-admin --namespace artesca-auth \
        --output jsonpath='{.data.password}' | base64 -d)
    
  3. Generate an administrator access token.

    Note

    Administrator access tokens expire after 60 seconds. The get_admin_token function generates a new token for each command.

    [artesca-os@bootstrap ~]$
    
    get_admin_token() {
        curl -s -k "${URL}/auth/realms/master/protocol/openid-connect/token" \
            -d "client_id=admin-cli" \
            -d "username=admin" \
            --data-urlencode "password=${KC_ADMIN_PASSWORD}" \
            -d "grant_type=password" | \
            jq -cr '.access_token'
    }
    get_admin_token
    
    <administrator access token>
    

    If the command returns null, check the URL and KC_ADMIN_PASSWORD values.

  4. List the local users.

    [artesca-os@bootstrap ~]$
    
    curl -s -k -H "Authorization: Bearer $(get_admin_token)" \
        "${URL}/auth/admin/realms/artesca/users?max=1000" | \
        jq -r '.[] | select(.federationLink == null) | [.username, (.email // "-"), .enabled] | @tsv' | column -t
    
    scality      change.me@scality.invalid  true
    <username>   <email>                    true
    
  5. Declare the local user whose password you want to reset, replacing <username> with a value from the first column of the previous output.

    [artesca-os@bootstrap ~]$
    
    KC_USER='<username>'
    
  6. Retrieve the user ID.

    [artesca-os@bootstrap ~]$
    
    USER_ID=$(curl -s -k -H "Authorization: Bearer $(get_admin_token)" \
        -G "${URL}/auth/admin/realms/artesca/users" \
        --data-urlencode "username=${KC_USER}" -d "exact=true" | \
        jq -cr '.[0].id')
    echo ${USER_ID}
    

    The command returns an ID such as f475c5b1-75cf-4d93-bc49-7c3c14ecf608. If it returns null, check the KC_USER value.

  7. Enter the new temporary password. The password is not displayed.

    [artesca-os@bootstrap ~]$
    
    read -r -s -p "New password: " NEW_PASSWORD; echo
    
  8. Reset the password.

    [artesca-os@bootstrap ~]$
    
    jq -n --arg pw "${NEW_PASSWORD}" '{type: "password", value: $pw, temporary: true}' | \
        curl -s -k -w "\n%{http_code}\n" -X PUT \
            -H "Authorization: Bearer $(get_admin_token)" \
            -H "Content-Type: application/json" \
            "${URL}/auth/admin/realms/artesca/users/${USER_ID}/reset-password" \
            --data-binary @-
    
    204
    

    The command returns 204 when the password is reset. If it returns another code, the response body above the code gives the reason. A 400 usually means the password does not meet the password policy: enter another password and run this step again.

  9. Clear the passwords from the shell session.

    [artesca-os@bootstrap ~]$
    
    unset NEW_PASSWORD KC_ADMIN_PASSWORD
    

Log In With the New Password

  1. Open your web browser and navigate to the management UI URL.

  2. Log in with the local user name and the temporary password.

  3. Update your password and click Submit.

You are logged in to the ARTESCA management UI with the new password.