-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
[wip] Use hook for checkAccess #20035
Conversation
(Standard links)
|
if (is_null($contactID)) { | ||
$contactID = CRM_Core_Session::getLoggedInContactID(); | ||
} | ||
CRM_Utils_Hook::checkAccess(CRM_Core_DAO_AllCoreTables::getBriefName(get_class($this)), $action, $contactID, $values); |
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.
@eileenmcnaughton I'm guessing we may want to call core methods that already exist before we get to the hook invocation and would we want extensions to potentially override core functions e.g. result of CRM_Mailing_BAO_Mailing::acl
or whatever is that function?
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.
@seamuslee001 yeah - this is the function on the DAO class which would be overridden by various BAO classes
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.
@eileenmcnaughton I guess in my mind at least wouldn't that mean we end up with a lot of duplicated code around the place because you would want to copy n paste a fair chunk of this function on the other DAOs?
test this please |
@colemanw closing as a discussion point rather than a PR for review |
@eileenmcnaughton I opened #20170 with a modified version of this function. Notable differences:
|
Overview
@colemanw @seamuslee001 @totten - I decided to take a pass at the checkAccess function we discussed. This works in this limited context - with the trickiest part here being convergence on which pseudoconstant / string to use to denote the action. However, for v4 api we have the ability for update & delete with WHERE clauses - so mysql might make more sense - eg. 'WHERE id NOT IN ()';
Note the test class I touched is a pretty good starting place for finding 'already-tested-code-that-is-relevant'
Before
The way to prevent an unpermissioned update is the pre-hook - but this can't be tested before taking action
After
We have a starting point for how a hook might look to do a pre-check
Technical Details
Note this is an example of an existing pre-hook implementation
Comments