Have Drupal use one database for Login, other for everything else?

pip8786 - February 5, 2009 - 18:27

I'm making a site for an MMO Game where we want the logins shared between the site and the game. We don't want to copy over the login info every time it changes, so we would like to use the Game Database to authenticate users, but have the Drupal/Site Database handle everything else.

In other words, the Game DB has a table with:
userid, username, password

and everything else would be stored in the Drupal DB that is normally stored there. The username and password would be blank in the Drupal users table.

Is it possible to have Drupal check for authentication in the GameDB without having to hack core code? Would user_login_authenticate_validate be the right hook?

We would also possibly like to fetch data from a third DB if the user doesnt currently exist, in case they haven't logged onto the new system before. This would make it so our table would be purged of any old users, but we don't have to do that. We could copy the data over (from phpbb3).

Any recommendations, opinions, etc on the process are welcome.

Thanks
Philippe

Still looking for a bit of

pip8786 - February 6, 2009 - 02:30

Still looking for a bit of help on this :)

Hey Philippe, what's up? You

KingMoore - February 6, 2009 - 04:33

Hey Philippe, what's up?

You should be able to write a custom user authentication module that basically overrides the standard drupal authentication using hook_auth, and authenticates against your external DB using your custom code. See here:
http://drupal.org/node/190635

Also, I think the Facebook API module has an example (but don't quote me on that):
http://drupal.org/project/fb

Go Bus.

may be a bit different if

KingMoore - February 6, 2009 - 04:54

may be a bit different if you are using D6, see here:
http://drupal.org/node/114774#dist-auth

Here's a bit of a walkthrough:
http://www.darrenmothersele.com/content/using-external-data-source-drupa...

you could also check out

KingMoore - February 6, 2009 - 04:51

Thanks for all the replies,

pip8786 - February 6, 2009 - 18:42

Thanks for all the replies, KM, I'll be taking a look through all these links over the weekend :)

did you get something

KingMoore - February 15, 2009 - 23:59

did you get something sorted? did you realize that you know me from a previous life?

If your first name is Josh,

pip8786 - February 17, 2009 - 19:31

If your first name is Josh, then yes. :)

I haven't gotten it all working yet. Here is my code:
http://paste.bradleygill.com/index.php?paste_id=7179

When you login, it gives me a blank page. I have cleared the username and pass from the drupal users table to make sure it doesn't get it from there. Anything you see that I'm doing wrong?

hehe yeah that's me. I

KingMoore - February 17, 2009 - 22:46

hehe yeah that's me. I didn't see anything obliviously wrong, but I have never actually implemented this, just know it's possible. Maybe try a debugger to see where it's going wrong?

 
 

Drupal is a registered trademark of Dries Buytaert.