第29章 Business Central のグループ、ロール、およびユーザーの Security Management REST API

Red Hat Process Automation Manager は、Business Central ユーザーインターフェイスを使用せずに Red Hat Process Automation Manager でグループ、ロール、およびユーザーを管理する時に使用可能な Security Management REST API を提供します。この API のサポートにより、Business Central グループ、ロール、ユーザー、および付与したパーミッションの管理の容易化、自動化が可能です。

Security Management REST API を使用すると、以下のアクションが可能になります。

  • すべてのグループ、ロール、ユーザー、およびそれぞれに付与された権限に関する情報を取得する
  • グループとユーザーを作成、更新、または削除する
  • グループ、ロール、およびユーザーに付与された権限を更新する
  • ユーザーに割り当てられたグループとロールに関する情報を取得する

Security Management REST API 要求には以下のコンポーネントが必要です。

認証

Security Management REST API は、ユーザーロール admin に HTTP の Basic 認証またはトークンベースの認証を必要とします。お使いの Red Hat Process Automation Manager に設定されているユーザーロールを表示するには、~/$SERVER_HOME/standalone/configuration/application-roles.properties~/application-users.properties に移動します。

ユーザーに admin ロールを追加するには、~/$SERVER_HOME/bin に移動して以下のコマンドを実行します。

$ ./bin/jboss-cli.sh --commands="embed-server --std-out=echo,/subsystem=elytron/filesystem-realm=ApplicationRealm:add-identity(identity=<USERNAME>),/subsystem=elytron/filesystem-realm=ApplicationRealm:set-password(identity=<USERNAME>, clear={password='<PASSWORD>'}),/subsystem=elytron/filesystem-realm=ApplicationRealm:add-identity-attribute(identity=<USERNAME>, name=role, value=['admin'])"

ユーザーロールと Red Hat Process Automation Manager のインストールオプションの詳細は、Red Hat Process Automation Manager インストールの計画 を参照してください。

HTTP ヘッダー

Security Management REST API は、API 要求に以下の HTTP ヘッダーを必要とします。

  • Accept: 要求元のクライアントが受け付けるデータ形式:

    • application/json (JSON)
  • Content-Type: POST または PUT API 要求データ向けのデータ形式:

    • application/json (JSON)
HTTP メソッド

Security Management REST API は、API 要求に以下の HTTP メソッドを必要とします。

  • GET: 指定したリソースのエンドポイントから指定した情報を取得する
  • POST: リソースを作成または更新する
  • PUT: リソースを更新する
  • DELETE: リソースを削除する
ベース URL

Security Management REST API 要求のベース URL は http://SERVER:PORT/business-central/rest/ で、たとえば http://localhost:8080/business-central/rest/ となります。

注記

Business Central に組み込まれた Security Management、ナレッジストア、Process Automation Manager コントローラーの REST API ベース URL は、Business Central REST サービスとみなされるため、すべて同じです。

エンドポイント

特定のユーザーの /users/{userName} など、Security Management REST API のエンドポイントは、Security Management REST API ベース URL に追記する URI で、Red Hat Process Automation Manager 内で、対応するリソースやリソースタイプにアクセスする際に使用します。

/users/{userName} エンドポイントの要求 URL 例

http://localhost:8080/business-central/rest/users/newUser

要求データ

Security Management REST API の HTTP POST 要求は、データに JSON 要求のボディが必要になる場合があります。

POST 要求 URL と JSON 要求のボディデータの例

http://localhost:8080/business-central/rest/users/newUser/groups

[
  "newGroup"
]

29.1. REST クライアントまたは curl ユーティリティーを使用した Security Management REST API による要求送信

Security Management REST API を使用すると、Business Central ユーザーインターフェイスを使わずに Red Hat Process Automation Manager のグループ、ロール、およびユーザーを操作することができます。Security Management REST API 要求は、REST クライアントまたは curl ユーティリティーを使用して送信できます。

前提条件

  • Business Central をインストールし、実行している。
  • admin ユーザーロールで Business Central にアクセスできる。

手順

  1. [GET] /groups など、要求の送信先に適した API エンドポイント を特定し、Business Central からグループを取得します。
  2. REST クライアントまたは curl ユーティリティーで、/groups への GET 要求に以下のコンポーネントを記入します。ご自分のユースケースに合わせて、要求詳細を調整します。

    REST クライアントの場合:

    • Authentication: admin ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力します。
    • HTTP Headers: 以下のヘッダーを設定します。

      • Accept: application/json
    • HTTP method: GET に設定します。
    • URL: Security Management REST API ベース URL とエンドポイントを入力します。たとえば、http://localhost:8080/business-central/rest/groups となります。

    curl ユーティリティーの場合:

    • -u: admin ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力します。
    • -H: 以下のヘッダーを設定します。

      • Accept: application/json
    • -X: GET に設定します。
    • URL: Security Management REST API ベース URL とエンドポイントを入力します。たとえば、http://localhost:8080/business-central/rest/groups となります。
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/business-central/rest/groups"
  3. 要求を実行し、KIE Server の応答を確認します。

    サーバー応答の例 (JSON):

    [
      	{
    		"group1"
    	},
    	{
    		"group2"
    	}
    ]
  4. REST クライアントまたは curl ユーティリティーで、/users/{userName}/groups への POST 要求を以下のコンポーネントで送信し、ユーザーに割り当てられたグループを更新します。ご自分のユースケースに合わせて、要求詳細を調整します。

    REST クライアントの場合:

    • Authentication: admin ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力します。
    • HTTP Headers: 以下のヘッダーを設定します。

      • Accept: application/json
      • Content-Type: application/json
    • HTTP method: POST に設定します。
    • URL: Security Management REST API ベース URL とエンドポイントを入力します。たとえば、http://localhost:8080/business-central/rest/users/newUser/groups となります。
    • 要求のボディ: 新規グループ用の ID データを含む JSON 要求のボディを追加します。
    [
      "newGroup"
    ]

    curl ユーティリティーの場合:

    • -u: admin ロールを持つ Business Central ユーザーのユーザー名とパスワードを入力します。
    • -H: 以下のヘッダーを設定します。

      • Accept: application/json
      • Content-Type: application/json
    • -X: POST に設定します。
    • URL: Security Management REST API ベース URL とエンドポイントを入力します。たとえば、http://localhost:8080/business-central/rest/users/newUser/groups となります。
    • -d: 新規グループ用の ID データを含む JSON 要求のボディまたはファイル (@file.json) を追加します。
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/business-central/rest/users/newUser/groups" -d "["newGroup"]"
    curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/business-central/rest/users/newUser/groups" -d @user-groups.json
  5. 要求を実行し、KIE Server の応答を確認します。

    サーバー応答の例 (JSON):

    {
      "status": "OK",
      "message": "Groups [newGroup] are assigned successfully to user wbadmin"
    }

    要求エラーが発生した場合は、返されたエラーコードメッセージを確認して、それに応じて要求を調整します。