Reset password by using cURL restAPIs in wso2 IS

512 Views Asked by At

In wso2-IS 5.11, trying Update Password Operation through cURL restAPI command.

WSO2 IS Operation

I got reset password mail notification for below curl request,

$ curl -X POST -k -H "Authorization: Basic YWRxxxx=" -H "Content-Type: application/json" -d '{"user": {"username": "John","realm": "PRIMARY"},"properties": []}' "https://localhost:9445/api/identity/recovery/v0.9/recover-password?type=email&notify=true"

but instead of reset the password in reset-password-window , I need to pass the reset password values through cURL same like this, but this also requires Confirmation keycode with validity period and this is availlable in IDN_RecoveryDataTable as per this doc, so where this "IDN recovery data table" find out.? and shall I use same operation? or need to try some different use cases like , active and inactive user via cURL RestAPI ,and 3rd case Invalid password.

1

There are 1 best solutions below

0
On

It seems you are following the blog [1] and referring to ii) Update Password step.

IDN_RECOVERY_DATA is a table of the identity database where WSO2IS stores information about the recovery flow. But you don't have to worry about the data stored in the database.

If you are just trying to change the password of a user without sending an email, you can use SCIM APIs.

Following is an example to update the password of a user when the existing password is provided.

curl -X PATCH 'https://localhost:9443/scim2/Me' \
-H 'accept: application/scim+json' \
-H 'Content-Type: application/scim+json' \
-H 'Authorization: Basic {base64(username:currentPassword)}' \
-d '{ "schemas": [ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ], "Operations": [ { "op": "replace", "value": { "password": "newPassword" } } ]}'

If you want to send an email and void WSO2 UIs for creating the new password, you can change the email template to redirect the user to your UI once the user clicks the link in the email. Then use the confirmation code included in that link to invoke the password set-password API. The document [2] has information on the APIs related to the account recovery, available in WSO2 Identity Server 5.11.0.

For locking or disabling a user, you can use the SCIM APIs to patch the relevant user attributes.

[1] https://medium.com/@isurakarunaratne/password-recovery-wso2-identity-server-b80abe2bcc61

[2] https://docs.wso2.com/display/IS511/apidocs/account-recovery/