Single/Shared sign-on when logging in via vBulletin

Roi Danton - June 11, 2008 - 12:00
Project:Drupal vB
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

It would be fine if users login/logout at vBulletin and are logged in/logged out at Drupal, too - without redirecting the user from vB to Drupal upon Login/Logout (like described in the Readme).

I don't know how difficult it is to realize this or if this is possible at all with Drupal vb's approach & D5 or D6 or D7 + vb 3.x - but it would be THE reason (besides the other recent achievements this module did thanks to sun) to switch from vbDrupal to Drupal vb.

#1

sun - June 11, 2008 - 19:24
Title:Single/Shared sign-on when logging in via vBulletin?» Single/Shared sign-on when logging in via vBulletin

This requires a plugin for vBulletin, because Drupal does not know anything about what happens when users are in the forums. Since I'm a Drupal developer and not really familiar with vBulletin development, I am not able to develop this plugin. However, I'd be happy to assist with the concept, architecture, reviewing and testing, etc.

#2

Roi Danton - July 11, 2008 - 19:50

I had a first look into the vbdrupal product-drupal.xml (which didn't help me for now) & your drupalvb.module & drupalvb.inc. It seems for login/logout you just set vb cookies & for creating/deleting of users your module manipulates the vb db directly. The initial user mapping you do with _drupalvb_init_user_map, but for me it is interesting how you do realize the following:

new vBulletin users to log in to Drupal

I haven't found the proper function for this. Maybe you can give me a hint? =)

#3

sun - July 11, 2008 - 20:17

This happens in drupalvb_auth(), the core function of this integration module. When a user tries to logon and Drupal is unable to authenticate her, Drupal invokes all implementations of hook_auth() to allow external authentication providers. Thus, when a new user from vBulletin tries to logon in Drupal, DrupalvB checks the vBulletin database whether there is a user/password match. If there is one, the (existing) vBulletin user is saved as a Drupal user, the user id mapping is saved, and Drupal knows the vBulletin user.

#4

Roi Danton - July 12, 2008 - 14:04

Too bad, this doesn't help much.
So I have to call drupalvb_user() (or the appropriate Drupal functions) as the user performs login/logout/profile update actions within vbulletin. Let's see if I'm able to do this (currently i have no idea, maybe booting the Drupal environment in vb like done in vbdrupal_boot).

If this works and drupalvb_user_update + drupalvb_user_delete will be edited properly, the feature: updating user data in Drupal upon update in vBulletin && deleting users in Drupal upon deletion in vBulletin could be added.

The variables drupalvb_dual_login, drupalvb_acct_generation & drupalvb_acct_sync are set at admin settings in Drupal?

#5

sun - July 12, 2008 - 15:37

Yes, that's why I mentioned that we'd need a vB plugin for this purpose in #1. The plugin would have to implement the complete logic from Drupal vB, but the other way around.

It might be noteworthy that we were able to replace the user login form in vBulletin with a static copy of Drupal's login form and the login basically works. What's missing in this approach is a way to redirect a user back to the originating vBulletin page after a successful login. If that would work out, I don't think we would need a vBulletin plugin anymore.

And yes, all Drupal vB variables can be altered on the module settings page(s).

#6

Roi Danton - July 12, 2008 - 16:58

I think I've found a way to call drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) within vbulletin. If this also loads Drupals contributed modules (I assume: http://api.drupal.org/api/function/drupal_bootstrap/6) I should be able to use your module to do the rest login and sync stuff (so the vb plugin just calls your login/logout/update functions when the user does the proper actions in vb).

Unfortunately I'm currently using only Drupal 6 so I can't test it for now. But I think it isn't that hard to realize at all.

#7

sun - July 12, 2008 - 17:59

If that works, okay. However, please keep in mind that Drupal registers and possibly overwrites existing global variables of vBulletin when invoking drupal_bootstrap(). So at the very least, drupal_bootstrap() should be invoked within a function to prevent overriding of globals. Please note that this won't prevent Drupal from doing

<?php
$GLOBALS
['foo'] = 'bar';
?>

IIRC, all globals in D6 have been documented recently.

Also, you can't use Drupal vB's functions, because they assume that passed arguments are Drupal objects, not vBulletin objects. We would have to create new functions for this purpose.

#8

Roi Danton - July 13, 2008 - 09:09

Y, of course invoking drupal inside a function. @Globals: I'm checking for conflicts.

To load the user object in D I want to use user_load by submitting the username. Then hook_user should be called: &$account -> user object, &$edit -> empty (no form obj available and not needed).
But if the user doesn't exists in D (if the user doesn't login in Drupal between registration and login in vB) this won't work. So upon registration in vB the user has to be created in D somehow, too (lack of hook_auth in D6 :/ ).

#9

sun - September 18, 2008 - 21:50

Any updates?

#10

Roi Danton - September 25, 2008 - 18:23

I'm short in time and wanted to wait for more information on the mayor problem you posted in #230678: Port Drupal vB to 6.x. I'll work on it but can't talk about the when and how. If I'll get serious problems resp think it won't work I'll post an explanation here.

#11

sun - October 15, 2008 - 02:41

5.x-2.2 has been released now. So you're safe to base your work on this module.

#12

Roi Danton - October 15, 2008 - 11:03

Okay, thanks for the reminder! I'm currently working on a filter module + automated editor buttons for internal Drupal links/nodes/fields (I'll apply for a CVS account here soon), but I hope I'll be successful (depends on avail time) with this issue, too.

#13

Roi Danton - November 17, 2008 - 15:19

As you likely know I'm still busy with my own module and still have to look in detail into Inline API and WYSIWYG API. ;) Furthermore I recently stumbled upon this great forum module for Drupal so maybe its more senseful to use the time improving that than the integration for vB.

#14

tommac - April 10, 2009 - 23:31
Category:feature request» support request

I would also like to request a cleaner single sign-on between the two. I would be willing to volunteer to do the Vbulletin coding ... if someone could support me from the drupal side.

What I am thinking is the following mod:

1) integrated single sign on.
2) Single drupal header
3) Use of the drupal sidebar

Basically I would like to use all of the vbulletin features while still having the look and feel and all of the other benefits of drupal.

The first step is the integrated single sign on. In drupal what happens during signon? What is the signon code if being used outside of the site?

#15

Roi Danton - April 11, 2009 - 09:00

Drupal uses hook_user for user related actions (like login and logout). The module Shared Sign-On shares the sign-on information between multiple Drupal websites. That code might help to understand Drupals signon behaviour.

#16

tommac - April 11, 2009 - 20:19

I was looking at this page in wordpress :

http://codex.wordpress.org/Pluggable_Functions

Is there an easy way to do this in Drupal?

There is a wordpress->vbulletin bridge that takes advantage of these hooks.
http://www.vbulletin.org/forum/showthread.php?t=205388&highlight=wordpress

#17

Roi Danton - April 13, 2009 - 08:39

http://codex.wordpress.org/Pluggable_Functions

You can't alter the Drupal core functions but extend them by using the hooks.

As written above I tried to load Drupal inside vBulletin. This works as vbdrupal proofs and except of the overwritten globals and the increased db load this has no disadvantages.

What approach have you thought about?

#18

sun - April 13, 2009 - 16:18

@Roi: I wonder how you did this. I recently had to write a vB plugin that bootstraps Drupal - however, we can only bootstrap to Drupal's database system at max, because when Drupal tries to register the user session, you get a bunch of PHP warnings that PHP's session is already initialized and cannot be altered.

vbdrupal is no measure here, because it requires modifications to Drupal core (hacks).

#19

tommac - April 19, 2009 - 14:15

I installed your code and it does not work.

What needs to be done is:

wrap drupal login using hooks to point to the vblogin.

This way both drupal and vb use the same login and sessions.

With your thing ... people have to log in twice.

#20

Roi Danton - April 30, 2009 - 20:28

@Sun: I partly relied on vbdrupal during my tests. It seems that I've muddled something. :( You're right, in vbdrupal _drupal_bootstrap() is altered and uses vbdr_drupal_bootstrap (in vbdrupal/includes/vbdrupal/bootstrap.inc) to override the default phase control.

@Tommac: Suns code works but as you pointed out Drupal isn't hooked in vb. This issue exists to discuss about creating such hook. If you have certain ideas about "wrapping drupal login using hooks to point to the vblogin" it'd be nice if you could share them.

#21

silurius - May 15, 2009 - 22:24

Subscribing.

#22

prolific_one - November 10, 2009 - 12:05

Are there any updates on a vB redirect option? I have the dual login working fine but it would be so nice if somehow drupalvb would take vB's current sessionURL and return to vB after login.

For a while I did remove the name/pass textfields in vB and just changed the login.php?do=login replacement variable to /user?destination=forums. This required the forums user to just click a login button or link, then enter the username/pw in drupal with a redirect to the vB home page... But I still didn't get it to redirect to the post/thread that the user was viewing so I changed the replacement variables back to the README suggestions and re-added the name/pass textfields.

Hopefully we can get a better redirect option. Does anyone know how to pull the sessionURL from vB and send that text to drupal and then use the ?destination=[vB-SessionURL] optiion?

#23

Roi Danton - November 10, 2009 - 16:21

Good idea! When the session retrieving works this should be made as a patch.

Does anyone know how to pull the sessionURL from vB and send that text to drupal and then use the ?destination=[vB-SessionURL] optiion?

Does is help to have the session ID to get that sessionURL? (e.g. retrieve the bbsessionhash cookie of those users using cookies)
Or if the sessionURL is available in vB this string can be included into your replacement variable so Drupal can use it. This is what you already proposed. -.- Asking at vb.org could be more successful.

#24

Roi Danton - November 15, 2009 - 11:34

Have you tried /user?destination=$session[sessionurl] as replacement variable? This works if the variable $session is available in the template where the variable is replaced. Since $session[sessionurl] is used in many templates the chances are good that this works.

Please report back if this works, I can't test this where I am currently.

 
 

Drupal is a registered trademark of Dries Buytaert.