-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Role Permissions are not respected in Child Groups #358
Comments
Baseline: SilverStripe 4.2.x-dev First step - try and reproduce without subsites:
Try and reproduce with subsites 2.1.x-dev:
Reproduced |
Ok the problem is that |
This is going to be nasty because of how much SQL the existing subsites code is generating to perform these checks. I'll summarise my thinking around how permissions should be working before I change anything: Subsites should be an extension layer over the top of the ACL system we have for admin. It's currently being a bit too intrusive which is what's causing this bug. We should delegate most of the actual permission checks to core while using subsite state modification to set the subsite context for which to check the member's permissions. The primary concern of this permission check logic should be whether or not a user can log into the admin area for a given subsite. Individual permission checking should be done using core checks in the context of the current subsite: The rest of the permission checks in this area should come after this precursor config i.e. "we validate that the user can access this subsite generally, so let's continue with 'can edit page', 'can view files' etc checks in this subsite now." Groups are not specific to subsites, they're global. There are two situations:
Check logic should be:
@ScopeyNZ @raissanorth would you mind sanity checking my thinking on this before I go further into it? * Note that in the context where I said "do not interject at all" this might mean returning a list of "accessible subsites" that includes the "main site" which is not a physical Subsite object but represents the default site. |
I'm not that familiar with subsites - but wouldn't the logic be:
In other words - keep it as simple as possible. Return false if the group is not in the "site whitelist" - delegate in all other cases and let other permissions be checked. Returning true should be avoided. I might be misunderstanding. I also really wanted to make a flow chart. |
Correct, we would only be returning null to delegate or false if we know for sure that the group doesn't have access to the current subsite |
Ok I've made a PR at #388 which I think fixes this issue |
Sorry, I've made a mistake with this. I need to reimplement some of the logic that was there. Here's my thinking of how permission checks should work for subsites: Get all available subsitesMethod: Logic:
This should keep the handling of group roles in Get all available subsites for the current controllerMethod: Logic:
Check whether a member can access the controller given the current subsiteMethod: Logic:
There's an opportunity to simplify and refactor here. Return a list of subsites that a user can do ANYTHING inMethod: Logic:
This method is correct I think. If we did the above we'd have a chain of each method into the other, while each provides their own benefit. The original statement from me was: I think what we need to ensure is that subsites deliberately return false for permission checks where the member's group is not allowed in a certain subsite. From then on, a permission check for a certain code can be handled by core. I need to rest my brain for a bit, but I think there's something about that that isn't working correctly at the moment. Again, this module seems to be working correctly, but silverstripe/silverstripe-securityreport#38 points out that there's a bug in the public API since this code isn't working (it's returning all subsites, not just the one that the user's group is allowed to access): $subsites = Subsite::accessible_sites(
'SITETREE_EDIT_ALL',
true,
"Main site",
$this->owner
);
return implode(', ', $subsites->column('Title')); Context for above code where it's a bug: |
We've had to revert the original PR because it didn't completely the fix the problem, and it introduced regressions which other modules are relying on. |
Affected Version
Tested on SilverStripe 4.0.3 and SilverStripe 4.1
Description
We tried to use roles in combination with sub-groups, but we notices these permissions are displayed correctly on the users panel in the Security tab. But are not giving the expected result.
More specifically: if we make a role 'Edit Pages' with the permission 'Access to Pages section' and set that role to the group 'Content Editors', and create a sub-group 'Content Editors Company A' under 'Content Editors'. The users in that group cannot access the pages section...
Steps to Reproduce
The text was updated successfully, but these errors were encountered: