Node.js All Tenants Check Examples
1. Perform All Tenants Check
To validate permissions irrespective of the tenant, you can use the permit.AllTenantsCheck function. This function determines if a user has permissions for a specified action on a resource across all tenants, the response will be a list of tenants in which the user is allowed to perform the request.
note
You can also find information about the All tenants check in the Permit Authorization Redoc.
To perform this check, send a GET request to the /allowed/all-tenants
endpoint with the following parameters:
- user: The identifier of the user for whom you want to check permissions.
- action: The action to check permission for (e.g., read, write, delete).
- resource: The resource type on which the action is being performed.
- context: Additional context information for the permission check (optional).
- sdk: The identifier for the SDK making the request.
curl 'https://pdp-api.permit.io/allowed/all-tenants' \
-X GET \
-H 'Authorization: Bearer API_SECRET_KEY' \
-D '{ "user": "employee1", "action": "read", "resource": "document", "context": {}, "sdk": "node" }'
Upon successful completion, the API returns a response indicating whether the user is allowed to perform the specified action across all tenants.
2. Example Response
If the user is permitted, the response will indicate success along with a message confirming the permission:
{
"allowed": true,
"message": "User 'employee1' is permitted to read the document across all tenants."
}
If the user is not permitted, the response will indicate denial of permission.