Manage access permissions for a template
Restricting access to private resources is a very important part of FastReport Corporate Server. A flexible access system allows you to set a restriction or grant permission to each resource separately, specifying the persons who can access the resource.
Getting started
You will need the following tools and features:
Knowledge on how to use API key in FastReport Corporate Server.
This article does not include the information about authentication and authorization.
The curl tool.
Any other REST client will work, however, the examples are provided for curl.
A report template.
To learn how to upload a report template, see the article Upload a new template.
Active subscription for FastReport Corporate Server.
Internet access.
Instructions
To view the current resource access permissions, make a
GET
request tohttps://fastreport.cloud/api/rp/v1/Templates/File/{id}/permissions
substituting{id}
with the template identifier.A sample request.
curl -X GET "https://fastreport.cloud/api/rp/v1/Templates/File/5fc9ece6b792c90001d94b13/permissions" -H "accept: text/plain"
A sample response.
{ "ownerId": "5af5a8dc-8cb0-40f9-ac99-ca2533fa4491", "owner": { "create": "All", "delete": "All", "execute": "All", "get": "All", "update": "All", "administrate": "All" }, "groups": null, "other": null, "anon": null }
In this example, the owner has full access to the report template.
To add new permissions, make a
PUT
request tohttps://fastreport.cloud/api/rp/v1/Templates/File/{id}/permissions
, substituting{id}
with the template identifier.A sample model.
{ "permission": "PermissionsModel", "permissionType": "string one of [ Owner, Group, Other, Anon ]", "groupId": "string id, pass only if permissionType=Group", "ownerId": "string id, pass only if permissionType=Owner" }
A sample request, that adds read permissions for all members of the subscription.
curl -X PUT "https://fastreport.cloud/api/rp/v1/Templates/File/5fc9ece6b792c90001d94b13/permissions" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -d "{ \"permission\": { \"get\": \"All\", }, \"permissionType\": \"Other\",}"
A sample response.
{ "ownerId": null, "owner": null, "groups": null, "other": { "create": "None", "delete": "None", "execute": "None", "get": "All", "update": "None", "administrate": "None" }, "anon": null }
To revoke permissions, make a
DELETE
request tohttps://fastreport.cloud/api/rp/v1/Templates/File/{id}/permissions
, substituting{id}
with the template identifier.A sample model.
{ "permission": "PermissionsModel", "permissionType": "string one of [ Owner, Group, Other, Anon ]", "groupId": "string id, pass only if permissionType=Group", "ownerId": "string id, pass only if permissionType=Owner" }
An example of a request that prohibits file downloading for members of the subscription.
curl -X DELETE "https://fastreport.cloud/api/rp/v1/Templates/File/5fc9ece6b792c90001d94b13/permissions" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -d "{ \"permission\": { \"get\": 4, }, \"permissionType\": \"Other\"}"
A sample response.
{ "ownerId": null, "owner": null, "groups": null, "other": { "create": "None", "delete": "None", "execute": "None", "get": -5, "update": "None", "administrate": "None" }, "anon": null }
Please, note: The response received contains information about the access permissions of members of the subscription -5; information about permissions is stored compactly in the bit flags.
All = -1 Download = 4 Allow permissions All 0 | All = 1111 1111 1111 1111 1111 1111 1111 1111 = -1 Revoke Download 0 | All & ~Download = 1111 1111 1111 1111 1111 1111 1111 1011 = -5
In the case above, all new permissions will be available to all users of the subscription. To avoid this situation, assign permissions without
All
.-1 | ~All & Entity & Count & Permission = 1011
To grant a specific set of permissions, revoke the All permissions and then grant specific permissions.