第29章 Security Management REST API for Business Central groups, roles, and users
Red Hat Decision Manager provides a Security Management REST API that you can use to manage the groups, roles, and users in Red Hat Decision Manager without using the Business Central user interface. This API support enables you to facilitate and automate management of Business Central groups, roles, users, and granted permissions.
With the Security Management REST API, you can perform the following actions:
- Retrieve information about all groups, roles, users, and their granted permissions
- Create, update, or delete groups and users
- Update granted permissions for groups, roles, and users
- Retrieve information about groups and roles assigned to the users
Security Management REST API requests require the following components:
- Authentication
The Security Management REST API requires HTTP Basic authentication or token-based authentication for the user role
admin. To view configured user roles for your Red Hat Decision Manager distribution, navigate to~/$SERVER_HOME/standalone/configuration/application-roles.propertiesand~/application-users.properties.To add a user with the
adminrole, navigate to~/$SERVER_HOME/binand run the following command:$ ./add-user.sh -a --user <USERNAME> --password <PASSWORD> --role adminFor more information about user roles and Red Hat Decision Manager installation options, see Planning a Red Hat Decision Manager installation.
- HTTP headers
The Security Management REST API requires the following HTTP headers for API requests:
Accept: Data format accepted by your requesting client:-
application/json(JSON)
-
Content-Type: Data format of yourPOSTorPUTAPI request data:-
application/json(JSON)
-
- HTTP methods
The Security Management REST API supports the following HTTP methods for API requests:
-
GET: Retrieves specified information from a specified resource endpoint -
POST: Creates or updates a resource -
PUT: Updates a resource -
DELETE: Deletes a resource
-
- Base URL
The base URL for Security Management REST API requests is
http://SERVER:PORT/decision-central/rest/, such ashttp://localhost:8080/decision-central/rest/.注記The REST API base URL for the Security Management, Knowledge Store, and Decision Manager controller built into Business Central are the same because all are considered part of Business Central REST services.
- Endpoints
Security Management REST API endpoints, such as
/users/{userName}for a specified user, are the URIs that you append to the Security Management REST API base URL to access the corresponding resource or type of resource in Red Hat Decision Manager.Example request URL for
/users/{userName}endpointhttp://localhost:8080/decision-central/rest/users/newUser- Request data
HTTP
POSTrequests in the Security Management REST API may require a JSON request body with data to accompany the request.Example POST request URL and JSON request body data
http://localhost:8080/decision-central/rest/users/newUser/groups[ "newGroup" ]
29.1. Sending requests with the Security Management REST API using a REST client or curl utility リンクのコピーリンクがクリップボードにコピーされました!
The Security Management REST API enables you to manage the groups, roles, and users in Red Hat Decision Manager without using the Business Central user interface. You can send Security Management REST API requests using any REST client or curl utility.
Prerequisites
- Business Central is installed and running.
-
You have
adminuser role access to Business Central.
Procedure
-
Identify the relevant API endpoint to which you want to send a request, such as
[GET] /groupsto retrieve groups in Business Central. In a REST client or curl utility, enter the following components for a
GETrequest to/groups. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Business Central user with the
adminrole. HTTP Headers: Set the following header:
-
Accept:application/json
-
-
HTTP method: Set to
GET. -
URL: Enter the Security Management REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/groups.
For curl utility:
-
-u: Enter the user name and password of the Business Central user with theadminrole. -H: Set the following header:-
Accept:application/json
-
-
-X: Set toGET. -
URL: Enter the Security Management REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/groups.
curl -u 'baAdmin:password@1' -H "Accept: application/json" -X GET "http://localhost:8080/decision-central/rest/groups"-
Authentication: Enter the user name and password of the Business Central user with the
Execute the request and review the KIE Server response.
Example server response (JSON):
[ { "group1" }, { "group2" } ]In your REST client or curl utility, send another API request with the following components for a
POSTrequest to/users/{userName}/groupsto update the groups assigned to a user. Adjust any request details according to your use case.For REST client:
-
Authentication: Enter the user name and password of the Business Central user with the
adminrole. HTTP Headers: Set the following header:
-
Accept:application/json -
Content-Type:application/json
-
-
HTTP method: Set to
POST. -
URL: Enter the Security Management REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/users/newUser/groups. - Request body: Add a JSON request body with the identification data for the new group:
[ "newGroup" ]For curl utility:
-
-u: Enter the user name and password of the Business Central user with theadminrole. -H: Set the following headers:-
Accept:application/json -
Content-Type:application/json
-
-
-X: Set toPOST. -
URL: Enter the Security Management REST API base URL and endpoint, such as
http://localhost:8080/decision-central/rest/users/newUser/groups. -
-d: Add a JSON request body or file (@file.json) with the identification data for the new group:
curl -u 'baAdmin:password@1' -H "Accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/decision-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/decision-central/rest/users/newUser/groups" -d @user-groups.json-
Authentication: Enter the user name and password of the Business Central user with the
Execute the request and review the KIE Server response.
Example server response (JSON):
{ "status": "OK", "message": "Groups [newGroup] are assigned successfully to user wbadmin" }If you encounter request errors, review the returned error code messages and adjust your request accordingly.