-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix permissions for non-administrators #214
Conversation
This test is failing:
Shouldn't this be simply Neutral means to let the normal entity access handler take care of it. If this is OK for viewing the group content, then it should also be OK for the other operations right? To me this seems strange, if we |
Ok I think that this is the actual intention.
|
What we also need is a comprehensive set of KernelTests that check all access related use cases. Unit tests don't cut it in this case. I suppose we had a bunch of access tests in D7, it wouldn't be bad to start porting these. |
I have restored the functionality that returns Here is the implementation of
The test is failing because of a random failure in |
I think when this was originally added we were actually checking a permission not an operation. So this changed at some point and the function didn't follow? |
That's very well possible, that would explain the strange implementation. |
Well, only saying it because I remember adding it originally but I am pretty sure it was before there was a |
Not exactly :) The idea of That entity can be:
So basically this function should figure out for us what's the relation of the entity to OG, and then to iterate over all the possible cases, and return early if an access was granted. Also, fully agree we need Kernel test to assert the functionality:) |
I still don't understand it, how is 'administer group' an OG related operation on an entity? Operations are 'view', 'edit', 'delete' and 'create'. 'Administer group' is a permission. |
Let's take an imaginary OG permission called But we don't know yet what is the relation of the entity to OG. Is it a group? A group content? A group content with multiple groups?
If not clear, we can have a quick skype :) |
OK that's clear, but then we shouldn't call it an operation, but a permission, that seems to be the whole cause of my confusion :) |
The only call to Maybe we should make a clear separation between checking access based on permissions, and access based on operations. |
Indeed, this is wrong in OG8. It should follow the same logic we have in OG7's |
@amitaibu do you want the separation of permissions and operations in scope of this ticket? Or test coverage? I didn't do test coverage yet since none of this is currently covered by a proper integration test, and I'm afraid that any proper test coverage will be greatly enlarging the scope of this. I'd like to keep the scope of this manageable. If you want I can look into providing a single dedicated test that proves the bug and its fix, and then later on we can provide more complete coverage. This is blocking a feature request in our project at the moment. We have a role similar to a 'group moderator' which has elevated permissions inside their groups, but they do not have 'administer group' permissions. |
} | ||
|
||
$access = OgAccess::userAccessEntity($operation, $entity, $account); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'm ok with keeping this PR with a small scope (and we can have tests as follow up), but I think this part is still wrong. For example, if the bundle == 'article' and operation == 'update', it should be converted to something like:
$access = OgAccess::userAccessEntity('update own article content', $entity, $account) && $entity>getUserId() == $account->uid || OgAccess::userAccessEntity('update any article content', $entity, $account);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case, it's ready for merge, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this should be good to go. I'll make a followup issue to provide test coverage.
Thanks. |
The logic in
og_entity_access()
is faulty. It is callingOgAccess::userAccessEntity()
with the operation 'administer group', but this is invalid, the only allowed entity operations are 'view', 'create', 'update' and 'delete'.It also seems that some of the other code in
og_entity_access()
are earlier attempts for working around this bug.The solution seems pretty simple, if the user has the 'administer group' permission, then we simply return
AccessResult::neutral()
, which will grant access according to the user's normal privileges.Let's see what this breaks.