How to modify and delete grants and roles in the new Role/permissions system.
11 replies
Last updated: Jun 15, 2021
A
Hi, with the new Role/permissions system is it possible to:• Delete an existing grant from a role (maybe a
deleting a user role , but deleting the role itself so that it doesn't show up when you fetch the list of roles through the
DELETErequest to the
/grantsendpoint?) • Delete an existing role? Not
deleting a user role , but deleting the role itself so that it doesn't show up when you fetch the list of roles through the
/rolesendpoint.
Jun 14, 2021, 11:03 PM
Hi User! You can only modify grants for roles you have created yourself. Same goes for delete
Jun 15, 2021, 12:13 AM
A
Hi
https://www.sanity.io/docs/roles-reference •
https://www.sanity.io/docs/roles
user P
, thanks that's good to know! Is there any documentation on how the request should look like for modifying/deleting grants (and deleting custom roles that I created, if that is possible)? I looked through a couple docs but wasn't able to find anything.• https://www.sanity.io/docs/roles-reference •
https://www.sanity.io/docs/roles
Jun 15, 2021, 12:16 AM
Looks like the docs might be missing for creating grants atm, but you should be able to create a grant by POSTing to with the payload:
The permissions resource ids you can find at
/v2021-06-07/projects/{{project_id}}/grants
{ "roleName": "role-name", "permissionName": "<permissionName>", "permissionResourceId": "<resourceId>", "params": { } }
/v2021-06-07/projects/{{project_id}}/permissionResources
Jun 15, 2021, 12:22 AM
Looks like we have a bug when it comes to deleting custom roles. I’ll get a fix rolled out ASAP tomorrow morning (CET-time)
Jun 15, 2021, 12:23 AM
A
Looks like we have a bug when it comes to deleting custom roles. I’ll get a fix rolled out ASAP tomorrow morning (CET-time)Awesome, thank you!
Jun 15, 2021, 12:25 AM
Np. Sorry for the inconvenience. The route should be under
DELETE /v2021-06-07/projects/:id/roles/:roleName
Jun 15, 2021, 12:27 AM
A
What would the request look like for deleting grants? Would it be something like
DELETE /v2021-06-07/projects/:id/grantswith
roleName,
permissionNameand
permissionResourceIdspecified in the body?
Jun 15, 2021, 12:32 AM
A
Awesome! Thank you again for the help, I really appreciate it 🙌
Jun 15, 2021, 12:33 AM
A
Great! thanks for letting me know :D
Jun 15, 2021, 3:50 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.