3

To get contact data via the API you only need the 'access CiviCRM' permission, as long as you have access to the contact in question somehow (via an ACL or whatever). But to get address data for the same contact you need the 'view all contacts' permission. Is there a reason address data is more locked down? Can I override it?

Our use case is: a third-party website is accessing Civi via the REST API. This website is managed by a third-party, so I don't want to use an API key that gives them full database access. So I've set up a user who only has access to the relevant contacts. I can get the basic contact data fine, but I can't get their addresses without altering this global api permission requirement.

I'm just a bit nervous about changing this in case it's going to open any security holes elsewhere...

Here's the code in question, in CRM/Core/DAO/permissions.php :

  // Contact permissions
  $permissions['contact'] = array(
    'create' => array(
      'access CiviCRM',
      'add contacts',
    ),
    'delete' => array(
      'access CiviCRM',
      'delete contacts',
    ),
    // managed by query object
    'get' => array(),
    'update' => array(
      'access CiviCRM',
      'edit all contacts',
    ),
    'getquick' => array(
      array('access CiviCRM', 'access AJAX API'),
    ),
  );

  // Contact-related data permissions.
  // CRM-14094 - Users can edit and delete contact-related objects using inline edit with 'edit all contacts' permission
  $permissions['address'] = array(
    'get' => array(
      'access CiviCRM',
      'view all contacts',
    ),
    'default' => array(
      'access CiviCRM',
      'edit all contacts',
    ),
  );

Emails, phone numbers, websites, instant messaging etc. all use the same 'view all contacts' requirement.

1 Answer 1

1

According to the API Security page, this is expected behaviour - only the Contact API applies ACLs and such.

Looks like the best solution is to write a custom API that limits available data.

1
  • Yes, I agree with this analysis. In 4.7 there are some underying changes in the api that lay the ground work for applying ACLs to addresses & other tables (& this could be backported to 4.6) but the extra step of adding the ACLs has not yet been done (note that if you would prefer to fund that work in core than write a custom api you can go through the paid issue queue - civicrm.org/paid-issue-queue - this would obviously benefit others if you did)
    – eileen
    Oct 12, 2015 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.