-
Notifications
You must be signed in to change notification settings - Fork 20
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 for #101 (access to restricted resources) #102
Conversation
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.
Thanks for sending a PR, @beko1997! Appreciate that :)
Left a few inline comments, but also want to discuss the way the conditions are applied in get_versions/getlist... the logic seems quite complex, primarily due to the check for access_resource_group_enabled causing 3 different scenarios to be needed. It also only checks resource groups and not, say, context permissions, so I'm wondering if this is the best approach. It is pragmatic (better than no check at all) and should be fairly performant though, so, a pretty good start.
Have you looked at using the $obj->checkPolicy
method on modAccessibleObject
instances? We'd need to grab the modResource object (if it still exists) but then VersionX would support any type of policy.
@@ -37,12 +37,16 @@ | |||
$v = $versionx->getVersionDetails('vxResource',$versionid,true); | |||
if ($v !== false) |
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.
Ew, Mark-from-5-years-ago, y u no use braces 😧
@@ -399,6 +399,10 @@ public function getVersionDetails($class = 'vxResource',$id = 0, $json = false, | |||
/* Class specific processing */ | |||
switch ($class) { | |||
case 'vxResource': | |||
$resource = $this->modx->getObject('modResource',$v->get('content_id')); | |||
if(!$resource) { |
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.
This check should be removed; just because a resource no longer exists does not mean it should not be available in VersionX. Restoring resources that were deleted is kind of a big deal for a versioning plugin.
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, you're right. I will check for a better solution later on.
Indeed, it looks a bit complex. I'm also not 100% convinced this will cover all the possibilities for restricting access to a resource. It is primarily based on the MODX is using this for example for receiving the resource tree. But this iterates over all resources before deciding whether the user has access. Using this with VersionX2 will make things a lot slower (and messier).
This part is interesting, will check it later. Not having a 100% guarantee for having the corresponding I will spend a bit of time in the next few days on this PR. |
I'd be interested in seeing a new and improved version of this, but given the refactoring to controllers and processors it would likely need to be re-implemented. |
This PR will fix #101. The resource will be checked against access through the resource group.