To create a new password, you have to POST the password or its hash as a JSON object to the https://<IP-address-of-SPS>/api/passwords endpoint. For details, see Create a new object. The body of the POST request must contain a JSON object with the parameters listed in Element . The response to a successful POST message is a JSON object that includes the reference ID of the created password in its key attribute. You can reference this ID in other parts of the configuration, for example, to set the password of a user account. Note that you can use a password object for only one purpose, that is, you cannot reference a password object twice.
POST https://<IP-address-of-SPS>/api/configuration/passwords
Note that the GET method is not permitted on this endpoint, you cannot list the existing passwords. However, if you know the reference ID of a password, you can display its properties:
GET https://<IP-address-of-SPS>/api/configuration/passwords/<reference-ID-of-the-password;>
You cannot directly delete or modify a password, the DELETE and PUT methods are not permitted on password objects. To update a password, create a new one, then update the object that uses the old password to reference the new password.
Header name | Description | Required | Values |
---|---|---|---|
Content-Type | Specifies the type of the data sent. SPS uses the JSON format | Required | application/json |
session_id | Contains the authentication token of the user | Required | The value of the session ID cookie received from the REST server in the authentication response, for example, a1f71d030e657634730b9e887cb59a5e56162860. For details on authentication, see Authenticate to the SPS REST API. |
The following command creates a new password object.
curl -X POST -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/passwords --data '{"plain": "newpassword"}'
If you do not want to include the actual password in the request, the SHA-256 hash of the password is enough:
curl -X POST -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/passwords --data '{"hash": "$6$rounds=5000$If20/EFyQ4dW3dg/$xrECLfXgZlC2Xr1s257E2aZen42fM7R.sOGG9pkPy1x5ORTx6j03oPWexVlB3f5wnaZOQCBF.NjlDgyg2WEe./"}'
The response to a successful POST message is a JSON object that includes the reference ID of the created password in its key attribute.
For details of the meta object, see Message format.
{ "key": "faa96916-c85e-46ff-8697-f4cc5e596e7f", "meta": { "href": "/api/configuration/passwords/faa96916-c85e-46ff-8697-f4cc5e596e7f", "parent": "/api/configuration/passwords", "transaction": "/api/transaction" } }
The following table lists the typical status and error codes for this request. For a complete list of error codes, see Application level error codes.
Code | Description | Notes |
---|---|---|
201 | Created | The new resource was successfully created. |
400 | InvalidQuery | The requested filter or its value is invalid. |
401 | Unauthenticated | The requested resource cannot be retrieved because the client is not authenticated and the resource requires authorization to access it. The details section contains the path that was attempted to be accessed, but could not be retrieved. |
401 | AuthenticationFailure | Authenticating the user with the given credentials has failed. |
404 | NotFound | The requested object does not exist. |
405 | MethodNotAllowed | The method <method> is not allowed for this node. |
You cannot directly delete or modify a password, the DELETE and PUT methods are not permitted on password objects. To update a password, create a new one, then update the object that uses the old password to reference the new password. After you commit the transaction, SPS will automatically delete the old password. For details, see Change the admin password.
To change the password of the admin user, complete the following steps.
For details, see Open a transaction.
POST a JSON object containing the password or the hash of the password to the https://<IP-address-of-SPS>/api/passwords endpoint. For details, see Element . For example:
curl -X POST -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/passwords --data '{"plain": "mypassword"}'
If the operation is successful, the response includes a reference key to the new password object.
Modify the JSON object of the user to reference the key of the new password object, and PUT the modified JSON object to the https://<IP-address-of-SPS>/api/configuration/aaa/local_database/users/<key-of-the-user> endpoint. For example:
curl -X PUT -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/aaa/local_database/users/14322374245a7de542bbb04 --data '{"name": "admin", "password": "<key-of-the-new-password>"}'
For details, see Commit a transaction.
To change the password of the root user, complete the following steps.
For details, see Open a transaction.
POST a JSON object containing the password or the hash of the password to the https://<IP-address-of-SPS>/api/passwords endpoint. For details, see Element . For example:
curl -X POST -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/passwords --data '{"plain": "mypassword"}'
If the operation is successful, the response includes a reference key to the new password object.
PUT the reference key of the new password object to the https://<IP-address-of-SPS>/api/configuration/management/root_password endpoint. For example:
curl -X PUT -H "Content-Type: application/json" --cookie cookies https://<IP-address-of-SPS>/api/configuration/management/root_password --data '"<key-of-the-new-password>"'
Note that you must PUT the reference key as a JSON string, enclosed in double-quotes.
For details, see Commit a transaction.
© ALL RIGHTS RESERVED. Feedback Terms of Use Privacy Cookie Preference Center