4.3. サポートされている RBAC REST API エンドポイント
RBAC REST API は、Developer Hub でロール、パーミッション、条件付きポリシーを管理し、ロールとポリシーに関する情報を取得するためのエンドポイントを提供します。
4.3.1. ロール リンクのコピーリンクがクリップボードにコピーされました!
RBAC REST API は、Red Hat Developer Hub でロールを管理するために、次のエンドポイントをサポートします。
- [GET] /api/permission/roles
Developer Hub のすべてのロールを返します。
応答例 (JSON)
[ { "memberReferences": ["user:default/username"], "name": "role:default/guests" }, { "memberReferences": [ "group:default/groupname", "user:default/username" ], "name": "role:default/rbac_admin" } ]- [GET] /api/permission/roles/<kind>/<namespace>/<name>
Developer Hub の 1 つのロールに関する情報を返します。
応答例 (JSON)
[ { "memberReferences": [ "group:default/groupname", "user:default/username" ], "name": "role:default/rbac_admin" } ]- [POST] /api/permission/roles/<kind>/<namespace>/<name>
Developer Hub でロールを作成します。
Expand 表4.1 要求パラメーター 名前 説明 タイプ 要否 body作成される新しいロールの
memberReferences、group、namespace、name。リクエストの本文
必須
要求の body の例 (JSON)
{ "memberReferences": ["group:default/test"], "name": "role:default/test_admin" }応答の例
201 Created- [PUT] /api/permission/roles/<kind>/<namespace>/<name>
Developer Hub のロールの
memberReferences、kind、namespace、またはnameを更新します。要求パラメーター
要求の body には、
oldRoleオブジェクトとnewRoleオブジェクトが含まれています。Expand 名前 説明 タイプ 要否 body作成される新しいロールの
memberReferences、group、namespace、name。リクエストの本文
必須
要求の body の例 (JSON)
{ "oldRole": { "memberReferences": ["group:default/test"], "name": "role:default/test_admin" }, "newRole": { "memberReferences": ["group:default/test", "user:default/test2"], "name": "role:default/test_admin" } }応答の例
200 OK- [DELETE] /api/permission/roles/<kind>/<namespace>/<name>?memberReferences=<VALUE>
Developer Hub のロールから、指定されたユーザーまたはグループを削除します。
Expand 表4.2 要求パラメーター 名前 説明 タイプ 要否 kindエンティティーの種類
String
必須
namespaceエンティティーの namespace
String
必須
nameエンティティーの名前
String
必須
memberReferences関連するグループの情報
String
必須
応答の例
204- [DELETE] /api/permission/roles/<kind>/<namespace>/<name>
Developer Hub から、指定されたロールを削除します。
Expand 表4.3 要求パラメーター 名前 説明 タイプ 要否 kindエンティティーの種類
String
必須
namespaceエンティティーの namespace
String
必須
nameエンティティーの名前
String
必須
応答の例
204
4.3.2. パーミッションポリシー リンクのコピーリンクがクリップボードにコピーされました!
RBAC REST API は、Red Hat Developer Hub でパーミッションポリシーを管理するために、次のエンドポイントをサポートします。
- [GET] /api/permission/policies
すべてのユーザーのパーミッションポリシーリストを返します。
応答例 (JSON)
[ { "entityReference": "role:default/test", "permission": "catalog-entity", "policy": "read", "effect": "allow", "metadata": { "source": "csv-file" } }, { "entityReference": "role:default/test", "permission": "catalog.entity.create", "policy": "use", "effect": "allow", "metadata": { "source": "csv-file" } }, ]- [GET] /api/permission/policies/<kind>/<namespace>/<name>
指定されたエンティティー参照に関連するパーミッションポリシーを返します。
Expand 表4.4 要求パラメーター 名前 説明 タイプ 要否 kindエンティティーの種類
String
必須
namespaceエンティティーの namespace
String
必須
nameエンティティーに関連する名前
String
必須
応答例 (JSON)
[ { "entityReference": "role:default/test", "permission": "catalog-entity", "policy": "read", "effect": "allow", "metadata": { "source": "csv-file" } }, { "entityReference": "role:default/test", "permission": "catalog.entity.create", "policy": "use", "effect": "allow", "metadata": { "source": "csv-file" } } ]- [POST] /api/permission/policies
指定されたエンティティーのパーミッションポリシーを作成します。
Expand 表4.5 要求パラメーター 名前 説明 タイプ 要否 entityReferencekind、namespace、nameを含むエンティティーの参照値String
必須
permission特定のプラグイン、リソースタイプ、または名前からのパーミッション
String
必須
policyパーミッションのポリシーアクション (
create、read、update、delete、useなど)String
必須
effectポリシーを許可するかどうか
String
必須
要求の body の例 (JSON)
[ { "entityReference": "role:default/test", "permission": "catalog-entity", "policy": "read", "effect": "allow" } ]応答の例
201 Created- [PUT] /api/permission/policies/<kind>/<namespace>/<name>
指定されたエンティティーのパーミッションポリシーを更新します。
要求パラメーター
要求の body には、
oldPolicyオブジェクトとnewPolicyオブジェクトが含まれています。Expand 名前 説明 タイプ 要否 permission特定のプラグイン、リソースタイプ、または名前からのパーミッション
String
必須
policyパーミッションのポリシーアクション (
create、read、update、delete、useなど)String
必須
effectポリシーを許可するかどうか
String
必須
要求の body の例 (JSON)
{ "oldPolicy": [ { "permission": "catalog-entity", "policy": "read", "effect": "allow" }, { "permission": "catalog.entity.create", "policy": "create", "effect": "allow" } ], "newPolicy": [ { "permission": "catalog-entity", "policy": "read", "effect": "deny" }, { "permission": "policy-entity", "policy": "read", "effect": "allow" } ] }応答の例
200- [DELETE] /api/permission/policies/<kind>/<namespace>/<name>?permission={value1}&policy={value2}&effect={value3}
指定されたエンティティーに追加されたパーミッションポリシーを削除します。
Expand 表4.6 要求パラメーター 名前 説明 タイプ 要否 kindエンティティーの種類
String
必須
namespaceエンティティーの namespace
String
必須
nameエンティティーに関連する名前
String
必須
permission特定のプラグイン、リソースタイプ、または名前からのパーミッション
String
必須
policyパーミッションのポリシーアクション (
create、read、update、delete、useなど)String
必須
effectポリシーを許可するかどうか
String
必須
応答の例
204 No Content- [DELETE] /api/permission/policies/<kind>/<namespace>/<name>
指定されたエンティティーに追加されているすべてのパーミッションポリシーを削除します。
Expand 表4.7 要求パラメーター 名前 説明 タイプ 要否 kindエンティティーの種類
String
必須
namespaceエンティティーの namespace
String
必須
nameエンティティーに関連する名前
String
必須
応答の例
204 No Content- [GET] /api/permission/plugins/policies
すべての静的プラグインのパーミッションポリシーを返します。
応答例 (JSON)
[ { "pluginId": "catalog", "policies": [ { "isResourced": true, "permission": "catalog-entity", "policy": "read" }, { "isResourced": false, "permission": "catalog.entity.create", "policy": "create" }, { "isResourced": true, "permission": "catalog-entity", "policy": "delete" }, { "isResourced": true, "permission": "catalog-entity", "policy": "update" }, { "isResourced": false, "permission": "catalog.location.read", "policy": "read" }, { "isResourced": false, "permission": "catalog.location.create", "policy": "create" }, { "isResourced": false, "permission": "catalog.location.delete", "policy": "delete" } ] }, ... ]
4.3.3. 条件付きポリシー リンクのコピーリンクがクリップボードにコピーされました!
RBAC REST API は、Red Hat Developer Hub で条件付きポリシーを管理するための次のエンドポイントをサポートしています。
- [GET] /api/permission/plugins/condition-rules
Developer Hub で有効になっている利用可能なプラグインの利用可能な条件ルールパラメータースキーマを返します。
応答例 (JSON)
[ { "pluginId": "catalog", "rules": [ { "name": "HAS_ANNOTATION", "description": "Allow entities with the specified annotation", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "annotation": { "type": "string", "description": "Name of the annotation to match on" }, "value": { "type": "string", "description": "Value of the annotation to match on" } }, "required": [ "annotation" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } }, { "name": "HAS_LABEL", "description": "Allow entities with the specified label", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "label": { "type": "string", "description": "Name of the label to match on" } }, "required": [ "label" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } }, { "name": "HAS_METADATA", "description": "Allow entities with the specified metadata subfield", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "key": { "type": "string", "description": "Property within the entities metadata to match on" }, "value": { "type": "string", "description": "Value of the given property to match on" } }, "required": [ "key" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } }, { "name": "HAS_SPEC", "description": "Allow entities with the specified spec subfield", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "key": { "type": "string", "description": "Property within the entities spec to match on" }, "value": { "type": "string", "description": "Value of the given property to match on" } }, "required": [ "key" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } }, { "name": "IS_ENTITY_KIND", "description": "Allow entities matching a specified kind", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "kinds": { "type": "array", "items": { "type": "string" }, "description": "List of kinds to match at least one of" } }, "required": [ "kinds" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } }, { "name": "IS_ENTITY_OWNER", "description": "Allow entities owned by a specified claim", "resourceType": "catalog-entity", "paramsSchema": { "type": "object", "properties": { "claims": { "type": "array", "items": { "type": "string" }, "description": "List of claims to match at least one on within ownedBy" } }, "required": [ "claims" ], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } } ] } ... <another plugin condition parameter schemas> ]- [GET] /api/permission/roles/conditions/:id
指定された ID の条件を返します。
応答例 (JSON)
{ "id": 1, "result": "CONDITIONAL", "roleEntityRef": "role:default/test", "pluginId": "catalog", "resourceType": "catalog-entity", "permissionMapping": ["read"], "conditions": { "anyOf": [ { "rule": "IS_ENTITY_OWNER", "resourceType": "catalog-entity", "params": { "claims": ["group:default/team-a"] } }, { "rule": "IS_ENTITY_KIND", "resourceType": "catalog-entity", "params": { "kinds": ["Group"] } } ] } }- [GET] /api/permission/roles/conditions
全ロールの全条件のリストを返します。
応答例 (JSON)
[ { "id": 1, "result": "CONDITIONAL", "roleEntityRef": "role:default/test", "pluginId": "catalog", "resourceType": "catalog-entity", "permissionMapping": ["read"], "conditions": { "anyOf": [ { "rule": "IS_ENTITY_OWNER", "resourceType": "catalog-entity", "params": { "claims": ["group:default/team-a"] } }, { "rule": "IS_ENTITY_KIND", "resourceType": "catalog-entity", "params": { "kinds": ["Group"] } } ] } } ]- [POST] /api/permission/roles/conditions
指定されたロールの条件付きポリシーを作成します。
Expand 表4.8 要求パラメーター 名前 説明 タイプ 要否 result常に
CONDITIONALの値を持つString
必須
roleEntityRefRBAC ロールへの文字列エンティティー参照 (
role:default/devなど)String
必須
pluginId対応するプラグイン ID (
catalogなど)String
必須
permissionMappingパーミッションアクションの配列 (
['read', 'update', 'delete']など)String array
必須
resourceTypeプラグインによって提供されるリソースタイプ (
catalog-entityなど)String
必須
conditions条件によって結合されたパラメーターまたは配列パラメーターを含む条件 JSON
JSON
必須
nameロールの名前
String
必須
metadata.descriptionロールの説明
String
任意
要求の body の例 (JSON)
{ "result": "CONDITIONAL", "roleEntityRef": "role:default/test", "pluginId": "catalog", "resourceType": "catalog-entity", "permissionMapping": ["read"], "conditions": { "rule": "IS_ENTITY_OWNER", "resourceType": "catalog-entity", "params": { "claims": ["group:default/team-a"] } } }応答例 (JSON)
{ "id": 1 }- [PUT] /permission/roles/conditions/:id
指定された ID の条件ポリシーを更新します。
Expand 表4.9 要求パラメーター 名前 説明 タイプ 要否 result常に
CONDITIONALの値を持つString
必須
roleEntityRefRBAC ロールへの文字列エンティティー参照 (
role:default/devなど)String
必須
pluginId対応するプラグイン ID (
catalogなど)String
必須
permissionMappingパーミッションアクションの配列 (
['read', 'update', 'delete']など)String array
必須
resourceTypeプラグインによって提供されるリソースタイプ (
catalog-entityなど)String
必須
conditions条件によって結合されたパラメーターまたは配列パラメーターを含む条件 JSON
JSON
必須
nameロールの名前
String
必須
metadata.descriptionロールの説明
String
任意
要求の body の例 (JSON)
{ "result": "CONDITIONAL", "roleEntityRef": "role:default/test", "pluginId": "catalog", "resourceType": "catalog-entity", "permissionMapping": ["read"], "conditions": { "anyOf": [ { "rule": "IS_ENTITY_OWNER", "resourceType": "catalog-entity", "params": { "claims": ["group:default/team-a"] } }, { "rule": "IS_ENTITY_KIND", "resourceType": "catalog-entity", "params": { "kinds": ["Group"] } } ] } }応答の例
200- [DELETE] /api/permission/roles/conditions/:id
指定された ID の条件付きポリシーを削除します。
応答の例
204
4.3.4. ユーザー統計 リンクのコピーリンクがクリップボードにコピーされました!
licensed-users-info-backend プラグインは、ログインしたユーザーに関連するデータを取得するためのさまざまな REST API エンドポイントを公開します。
licensed-users-info-backend プラグインには追加の設定は必要ありません。RBAC バックエンドプラグインが有効になっていると、エンドポイントは policy.entity.read パーミッションによって保護されているため、エンドポイントにアクセスするには管理者ロールを割り当てる必要があります。
ユーザー統計エンドポイントのベース URL は http://SERVER:PORT/api/licensed-users-info です (例: http://localhost:7007/api/licensed-users-info)。
- [GET] /users/quantity
ログインしているユーザーの合計数を返します。
要求の例
curl -X GET "http://localhost:7007/api/licensed-users-info/users/quantity" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $token"応答の例
{ "quantity": "2" }- [GET] /users
ログインしているユーザーとその詳細のリストを返します。
要求の例
curl -X GET "http://localhost:7007/api/licensed-users-info/users" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $token"応答の例
[ { "userEntityRef": "user:default/dev", "lastTimeLogin": "Thu, 22 Aug 2024 16:27:41 GMT", "displayName": "John Leavy", "email": "dev@redhat.com" } ]- [GET] /users
ログインしているユーザーのリストを CSV 形式で返します。
要求の例
curl -X GET "http://localhost:7007/api/licensed-users-info/users" \ -H "Content-Type: text/csv" \ -H "Authorization: Bearer $token"応答の例
userEntityRef,displayName,email,lastTimeLogin user:default/dev,John Leavy,dev@redhat.com,"Thu, 22 Aug 2024 16:27:41 GMT"