sync_resources
To enforce permissions, you must first create resources and define actions that can be performed on those resources.
Then, you can create roles and assign them permissions for every resource/action combination. These roles can then be assigned to users.
For example: You can have the resource document
and the action create
for it.
We can give permission to an editor
role to create a document
, and we can assign the editor
role to a user named Bob
.
This function helps you sync your resources and actions with Permit:
resourcesTypes = {
"resources": [
{
"type": "task",
"actions": {
"list": {},
"retrieve": {},
"create": {},
"update": {},
"delete": {},
},
},
{
"type": "board",
"actions": {
"list": {},
"create": {},
"update": {},
"delete": {},
},
},
],
}
permit.sync_resources(resourcesTypes)
# SyncResources returns List[ResourceStub] type
# {
# "url": string,
# "data": [
# {
# "type": string,
# "description": string,
# "attributes": { },
# "name": string,
# "path": string,
# "id": string,
# "actions": [],
# "isBuiltIn": false
# }
# ]
# }