CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Why check for contact record when authenticating in utils/system/drupal.php?
Pages: [1]

Author Topic: Why check for contact record when authenticating in utils/system/drupal.php?  (Read 911 times)

greenmachine

  • I post occasionally
  • **
  • Posts: 58
  • Karma: 6
Why check for contact record when authenticating in utils/system/drupal.php?
December 03, 2009, 08:22:34 am
civimail.cronjob.php and other utility scripts require Drupal user credentials as input to authenticate before running the script. I ran into a problem with a client where the client had deleted the CiviCRM contact record associated/uf_match'd with the Drupal user account I had set up for my CiviMail cron job. Thus CiviMail was not sending out any messages until the client complained and I tracked it down.

It turned out the Drupal user account was still valid and working, but the client had deleted the associated contact record in CiviCRM, not recognizing it. The authenticate functions in Utils/System/Drupal.php and Joomla.php check not only for a valid Drupal/Joomla user account, but also for an associated/uf_match'd contact record. It seems like this might happen in other cases accidentally.

Why check for a CiviCRM contact record? The Drupal/Joomla username/password constitute the security check - I don't see how the presence of a CiviCRM record offers additional security assurance above and beyond checking the username/password credentials. I recommend dropping that part of the code in the future. Here's the snippet from the authenticate() function in Drupal.php

Code: [Select]
while ( $row = $query->fetchRow( DB_FETCHMODE_ASSOC ) ) {
            CRM_Core_BAO_UFMatch::synchronizeUFMatch( $user, $row['uid'], $row['mail'], 'Drupal' );
            $contactID = CRM_Core_BAO_UFMatch::getContactId( $row['uid'] );
            if ( ! $contactID ) {
                return false;
            }

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Why check for contact record when authenticating in utils/system/drupal.php?
December 03, 2009, 09:35:59 am

we plan to start using an individual contacts hash key as part of the cron script execution. the contact_id is also needed to store as an FK when we create activities (for civimail)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Why check for contact record when authenticating in utils/system/drupal.php?

This forum was archived on 2017-11-26.