processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

Add "page-level access control" to the Processwire access control system ? #483

Open er314 opened 1 year ago

er314 commented 1 year ago

Short description of the enhancement

Is it time to add "page-level access control" to the Processwire access control system ?

This topic was discussed several years ago, https://processwire.com/talk/topic/371-page-specific-permissions/ , and this led to the community-developped module UserGroups : https://github.com/apeisa/UserGroups , https://processwire.com/talk/topic/5658-alpha-release-usergroups-page-based-permissions/page/1/

Steps that explain the enhancement

Motive : One day or another, you come across a use case where you want to have :

So for example, one may want to have :

Expressed in terms of API, this would be :

// "roleVendorA" role has been previoulsy created
// assignment of this role to the relevant users has been previously set
// same for "roleVendorB"
// then, 
$pageProductA = new Page();
$pageProductA->template = "product";
$pageProductB = new Page();
$pageProductB->template = "product";
...
$pageProductA->addPermissionByRole("page-edit", "roleVendorA");  // equivalent of role assignment to template, but assigned to individual page
$pageProductA->save();
$pageProductB->addPermissionByRole("page-edit", "roleVendorB");  //
$pageProductB->save();

Or, expressed "in the style of UserGroups module", which doesn't use the native roles but its own dedicated groups (but as of today in my understanding this can't be set via API, only via GUI) :

// "groupVendorA" UserGroup has been previoulsy created
// assignment of users to this UserGroup has been previously set
// same for "groupVendorB"
// then, 
$pageProductA = new Page();
$pageProductA->template = "product";
$pageProductB = new Page();
$pageProductB->template = "product";
...
$pageProductA->addPermissionByGroup("page-edit", "groupVendorA");
$pageProductA->save();
$pageProductB->addPermissionByGroup("page-edit", "groupVendorB");
$pageProductB->save();

The expected result :

Why would the enhancement be useful to users?

The UserGroups module provides this capability (yet without the API side of things). But it would feel more "safe & natural" that this capability is provided by the core.