Drupal authentication tie in

Discussion in 'Technical Support' started by nickhaughton, Jun 27, 2011.

  1. nickhaughton Customer

    Hi All,

    We would like to tie in 68classiefieds with Drupal.

    Mainly what is needed is a way for people to sign in (and create user acounts) only once and not twice, separately in both systems.

    In order of preference I would like to do the following:

    1) have 68classifieds use Drupals user authentication mechanism, meaning it calls Drupal's appropriate php functions to log in a user etc.
    2) replicate database entries to 68classiefieds everytime they are altered in Drupal.
    3) run a nightly cron script to replicate the database entries.

    3) seems easiest, 2) almost as easy, and so far I no real idea how to go about 1), but would like that option best, as it does not duplicate data and generally seems "the right thing to do".

    My questions therefore:

    How does 68classifieds authenticate a user, which files and functions are relevant for this.

    How is authentication information kept once logged in (session?, cookies?, ...)?

    Is there documentation on this?

    Has someone done this before?

    Maybe there is a module that ties in with a common system (LDAP and the like)?


    Thank you in advance,
  2. John Snyder Staff

    Its not easy to replace the 68C authentication system as its files are included and called. However, you can duplicate the authentication by setting the session and or cookie. To fully understand how the login process works you can look at includes/system/classes/kernel/Login.php.
  3. nickhaughton Customer

    Hi John,

    Thanks for the speedy reply!

    To set the cookie I seem to need the following:
    * $this->_userData['username'] (data that I suppose I will dredge out of Drupal)
    * $this->_hash (algorithm and source data known)
    * $this->_cookieName (?)

    Now, there's a function setCookieName($name) in Login.php, but it's not used anywhere as far as I can see. Is the cookie name about to be changed in future versions (default right now is: classLogin)?

    Wouldn't it be easier to patch the function _getUserData($username) to go looking in Drupal for the right information? What speaks against this approach as opposed to creating and setting the cookie myself?

    Thanks in advance,
  4. John Snyder Staff

    Its a public method to change the cookie name, its not used but is available, the original intent I think was to allow the cookie name to be changed by the end user, but since its addition the login got reworked and I don't think its entirely possible as the admin area wouldn't work off a different cookie name unless the value was hard coded into the class.

    Personally, I would leave 68C intact and create a module to look up drupal user data after a successful login within 68C. Then log them in via custom code to drupal. Then you could do the same in drupal.

    If you want to replace 68C authentication, I'd just rewrite Login.php to duplicate drupal's login functions and map any public functions like logout or etc to their drupal equivalents. Then redirect login.php to the drupal login url.

    There is a change in the works for 4.2.4 to enable you to use the MySQL class within 68C to access multiple databases, so if you need that before then let me know.

    Send me a pm with a contact email address and I'll give you some snippets that should help you out, since I'm doing the module approach I mentioned earlier with vbulletin right now.

Share This Page