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

APIv4 - Allow creator to read UserJob and Queue records #23690

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jun 4, 2022

Overview

Refine the permissions for UserJob and Queue records.

ping @eileenmcnaughton

Before

  • Queue.get requires permission administer queues
  • UserJob.* requires permission access CiviCRM, but it only
    returns records if where the created_id matches current-user

After

  • Queue.get and UserJob.* follow similar rules
  • Users with permission administer queues can view all
  • Users with permission access CiviCRM can view items where created_id matches current-user

Technical Details

To r-run, I followed this approach:

  • Make sure the local deployment had 3 users admin, demo, advisor. The advisor has access CiviCRM but no other relevant permissions (eg administer CiviCRM, administer queues).
    • (Note: My local demo had some oddities in the civicrm_uf_match that needed to be cleaned-up before testing. This is entirely by-the-by.)
  • Create a UserJob and associated Queue (eg api explorer)
  • Alternate between CLI and SQL commands like:
    update civicrm_user_job set created_id = 123;
    update civicrm_user_job set created_id = 456;
    
    cv api4 -U advisor Queue.get checkPermissions=1 -T
    cv api4 -U admin Queue.get checkPermissions=1 -T
    cv api4 -U advisor UserJob.get checkPermissions=1 -T
    cv api4 -U admin UserJob.get checkPermissions=1 -T
    

Before
------

* `Queue.get` requires permission `administer queues`
* `UserJob.*` requires permission `access CiviCRM`, but it only
   returns records if where the `created_id` matches current-user

After
-----

* `Queue.get` and `UserJob.*` follow similar rules
* Users with permission `administer queues` can view all
* Users with permission `access CiviCRM` can view items where `created_id` matches current-user
@civibot
Copy link

civibot bot commented Jun 4, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor

Yep - this looks right - & I think your r-run testing covers it

@eileenmcnaughton eileenmcnaughton merged commit b586573 into civicrm:master Jun 4, 2022
@totten totten deleted the master-queue-visibility branch June 5, 2022 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants