5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBM Security Verify API を使ってユーザーのパスワードをリセットする

Last updated at Posted at 2022-11-15

はじめに

IBM Security Verify APIを利用して、ユーザーのパスワードをリセットする方法についてご紹介いたします。

APIのリファレンスは、以下のURLから確認できます。
https://docs.verify.ibm.com/verify/reference/resetuserpassword

image.png

1.IBM Security VerifyへのAPIクライアントの登録

OAuth アクセストークンを取得するために使用するクライアント ID とクライアントシークレットを準備します。
ブラウザで、IBM Security Verifyの管理画面にアクセスします。
https://<自分のテナント名>.verify.ibm.com/ui/admin

「セキュリティ」-「API アクセス」-「API クライアント」タブを開き、「APIクライアントの追加」をクリックします。
image.png

マニュアル上には必要な資格情報として以下の記載があります。

manageUserGroups (Manage users and groups) or manageAllUserGroups (Synchronize users and groups) or manageUserStandardGroups (Manage users and standard groups) or updateAnyUser (Update any user)

マニュアルに従ってアクセス権を与える資格を選択して、「保存」します。
- ユーザーおよび標準グループの管理

image.png

登録したAPIクライアントで、クライアントID/クライアント秘密鍵を確認します。
image.png

2.アクセストークンの取得

curl -X POST "https://<テナント名>.verify.ibm.com/oidc/endpoint/default/token" --header "Content-Type: application/x-www-form-urlencoded" --data-urlencode "grant_type=client_credentials" --data-urlencode "client_id=<クライアントID>" --data-urlencode "client_secret=<クライアント秘密鍵>"

取得したアクセストークンは赤枠部分になります。
image.png

3.ユーザーのパスワードリセット

ユーザーのパスワードリセットを行う方法が2種類あります。

  • 1.パスワード自動生成し、ユーザーにメール通知するパターン
  • 2.管理者が任意のパスワードを設定するパターン(ユーザーにメール通知するかどうかはオプション)

3.1.パスワード自動生成し、ユーザーにメール通知するパターン

passwordに"auto-generate"を指定します。

curl -i -X PATCH https://<テナント名>.verify.ibm.com/v2.0/Users/<userid>/passwordResetter --header "Content-Type: application/scim+json" --header "Authorization: Bearer <アクセストークン>" --data-raw "{\"Operations\":[{\"value\":{\"password\":\"auto-generate\",\"urn:ietf:params:scim:schemas:extension:ibm:2.0:Notification\":{\"notifyType\":\"EMAIL\",\"notifyPassword\":true,\"notifyManager\":false}},\"op\":\"replace\"}],\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"]}"

レスポンスコードは204でした。
image.png

ユーザープロファイルの優先言語に指定した言語でリセットされたパスワードが通知されます。
image.png

一次パスワードでログインすると、パスワード変更が求められます。
qiita(8).png

3.2.管理者が任意のパスワードを設定するパターン

password属性に任意のパスワードを設定します。
管理者が初期パスワードを指定するため、メールが見れないユーザーに初期パスワードを伝えることができるようになります。

curl -i -X PATCH https://<テナント名>.verify.ibm.com/v2.0/Users/<userid>/passwordResetter --header "Content-Type: application/scim+json" --header "Authorization: Bearer <アクセストークン>" --data-raw "{\"Operations\":[{\"value\":{\"password\":\"nininoP@ssword\\",\"urn:ietf:params:scim:schemas:extension:ibm:2.0:Notification\":{\"notifyType\":\"EMAIL\",\"notifyPassword\":true,\"notifyManager\":false}},\"op\":\"replace\"}],\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"]}"

image.png

ユーザープロファイルの優先言語に指定した言語でリセットされたパスワードが通知されます。
qiita(10).png

一次パスワードでログインすると、パスワード変更が求められます。
qiita(8).png

ユーザーへのメール通知をしないようにする場合は、"notifyType"を"NONE"にします。

curl -i -X PATCH https://<テナント名>.verify.ibm.com/v2.0/Users/<userid>/passwordResetter --header "Content-Type: application/scim+json" --header "Authorization: Bearer <アクセストークン>" --data-raw "{\"Operations\":[{\"value\":{\"password\":\"nininoP@ssword\\",\"urn:ietf:params:scim:schemas:extension:ibm:2.0:Notification\":{\"notifyType\":\"NONE\"}},\"op\":\"replace\"}],\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"]}"

最後に

IBM Security Verify API で ユーザーのパスワードをリセットする方法についてご紹介しました。

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?