Back to Redis

Password

content/operate/rs/references/rest-api/requests/users/password.md

latest7.7 KB
Original Source
MethodPathDescription
PUT/v1/users/passwordReplace passwords
POST/v1/users/passwordAdd a new password
DELETE/v1/users/passwordDelete a password

Update password {#update-password}

PUT /v1/users/password

Replaces the password list of the specified user with a single new password. If a username is not provided in the JSON request body, it replaces the password list of the authenticated user making this request instead.

Request {#put-request}

Example HTTP request

PUT /v1/users/password

Example JSON body

json
{
    "username": "The username of the affected user. If missing, default to the authenticated user.",
    "new_password": "the new (single) password"
}

Request headers

KeyValueDescription
Hostcnm.cluster.fqdnDomain name
Acceptapplication/jsonAccepted media type

Request body

The request must contain a JSON object with the following fields:

FieldTypeDescription
usernamestring(Optional) The username of the affected user. If missing, defaults to the authenticated user.
new_passwordstringThe new password (required)

Response {#put-response}

Returns a status code to indicate password update success or failure.

Error codes {#put-error-codes}

When errors are reported, the server may return a JSON object with error_code and message fields that provide additional information. The following are possible error_code values:

CodeDescription
password_not_complexThe given password is not complex enough (Only work when the password_complexity feature is enabled).
new_password_same_as_currentThe given new password is identical to one of the already existing passwords.
user_not_existUser does not exist.
unauthorized_actionUpdating another user's password is acceptable by an admin user only.

Status codes {#put-status-codes}

CodeDescription
200 OKSuccess, password changed.
400 Bad RequestBad or missing parameters.
401 UnauthorizedThe user is unauthorized.
403 ForbiddenInsufficient privileges.
404 Not FoundUser not found.

Add password {#add-password}

POST /v1/users/password

Adds a new password to the specified user's password list. If a username is not provided in the JSON request body, it adds the password to the password list of the authenticated user making this request instead.

Request {#post-request}

Example HTTP request

POST /v1/users/password

Example JSON body

json
{
    "username": "The username of the affected user. If missing, default to the authenticated user.",
    "new_password": "a password to add"
}

Request headers

KeyValueDescription
Hostcnm.cluster.fqdnDomain name
Acceptapplication/jsonAccepted media type

Request body

The request must contain a JSON object with the following fields:

FieldTypeDescription
usernamestring(Optional) The username of the affected user. If missing, defaults to the authenticated user.
new_passwordstringNew password to add (required)

Response {#post-response}

Returns a status code to indicate password creation success or failure. If an error occurs, the response body may include a more specific error code and message.

Error codes {#post-error-codes}

When errors are reported, the server may return a JSON object with error_code and message fields that provide additional information. The following are possible error_code values:

CodeDescription
password_not_complexThe given password is not complex enough (Only work when the password_complexity feature is enabled).
new_password_same_as_currentThe given new password is identical to one of the already existing passwords.
user_not_existUser does not exist.
unauthorized_actionUpdating another user's password is acceptable by an admin user only.

Status codes {#post-status-codes}

CodeDescription
200 OKSuccess, new password was added to the list of valid passwords.
400 Bad RequestBad or missing parameters.
401 UnauthorizedThe user is unauthorized.
403 ForbiddenInsufficient privileges.
404 Not FoundUser not found.

Delete password {#delete-password}

DELETE /v1/users/password

Deletes a password from the specified user's password list. If a username is not provided in the JSON request body, it deletes the password from the password list of the authenticated user making this request instead.

Request {#delete-request}

Example HTTP request

DELETE /v1/users/password

Example JSON body

json
{
    "username": "The username of the affected user. If missing, default to the authenticated user.",
    "old_password": "an existing password to delete"
}

Request headers

KeyValueDescription
Hostcnm.cluster.fqdnDomain name
Acceptapplication/jsonAccepted media type

Request body

The request must contain a JSON object with the following fields:

FieldTypeDescription
usernamestring(Optional) The username of the affected user. If missing, defaults to the authenticated user.
old_passwordstringExisting password to be deleted (required)

Response {#delete-response}

Error codes {#delete-error-codes}

When errors are reported, the server may return a JSON object with error_code and message fields that provide additional information. The following are possible error_code values:

CodeDescription
cannot_delete_last_passwordCannot delete the last password of a user.
user_not_existUser does not exist.
unauthorized_actionUpdating another user's password is acceptable by an admin user only.

Status codes {#delete-status-codes}

CodeDescription
200 OKSuccess, new password was deleted from the list of valid passwords.
400 Bad RequestBad or missing parameters.
401 UnauthorizedThe user is unauthorized.
403 ForbiddenInsufficient privileges.
404 Not FoundUser not found.