Skip to content
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(access): updates no longer mistakenly blocked in some scenarios #10103

Merged
merged 1 commit into from Aug 23, 2016

Conversation

mrclay
Copy link
Member

@mrclay mrclay commented Aug 20, 2016

In order to fix canEdit() in 1.9, update() needed to load a fresh copy of entity from the DB to check the persisted attributes. In that fix, 66eb9e6, a corner case was checked out of my paranoia that a dev would load an invisible entity with access control on, but try to delete it with access off.

I now believe this check was unnecessary (we never did similar checks for delete()). When the original canEdit() attributes issue was resolved in #9434, I should've made this change.

(replaces #10098)

@mrclay
Copy link
Member Author

mrclay commented Aug 20, 2016

If a developer turns off access control to give you an entity, and canEdit() is true, you should be allowed to update. It doesn't matter if the entity would be invisible to you under other circumstances. Right?

@mrclay
Copy link
Member Author

mrclay commented Aug 20, 2016

All that's really important is that caches (like memcache) check has_access_to_entity() before handing out an instance to user code.

@hypeJunction
Copy link
Contributor

Looks right. We need to audit cache habdling.

@hypeJunction
Copy link
Contributor

Actually, has_access_to_entity() need only be checked if access is not ignored. The only case for has access check without ignored access check is in notifications, IMO

@juho-jaakkola
Copy link
Member

LGTM

I just came across this last week. This bug forced me to make a direct database query to update the data instead of using the API. I agree that user should be allowed to update an entity if access is explicitly being ignored.

@hypeJunction
Copy link
Contributor

I would really like some tests on this - they would make it clearer what the "scenarios" are

@@ -379,4 +379,25 @@ public function testCreateWithContainerGuidEqualsZero() {
$user->delete();

}

public function testUpdateAbilityDependsOnCanEdit() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hypeJunction anything else we need to test here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the reverse. Revoking edit permissions via hook for an owner

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't think of anything else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ignored access tested elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and just added it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take another look tomorrow

@mrclay mrclay force-pushed the 10098_update branch 2 times, most recently from 02032b6 to d2acd02 Compare August 22, 2016 20:32
In order to fix `canEdit()` in 1.9, `update()` needed to load a fresh copy of
entity from the DB to check the persisted attributes. In that fix,
Elgg@66eb9e6,
a corner case was checked out of my paranoia that a dev would load an
invisible entity with access control on, but try to delete it with access
off.

I now believe this check was unnecessary (we never did similar checks for
`delete()`). When the original `canEdit()` attributes issue was resolved in
@hypeJunction
Copy link
Contributor

LGTM

@mrclay mrclay merged commit b0f8d16 into Elgg:2.2 Aug 23, 2016
@mrclay mrclay deleted the 10098_update branch August 23, 2016 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants