Extension:Phpbb Single Sign-On

It is finially here!!

This is a TRUE single sign on extension for mediawiki and phpBB. It does not use any funny tricks like curl or anything like that. It actually uses the phpbb sessions to do it all. When a user logs into the forum, they will be logged into the wiki. if a user logs out of the forum, they are logged out of the wiki. On my site I even removed the wiki login/out and replaced it with the forum login/out.

This plugin is a hacked version of Extension:AutomaticREMOTE USER - It was used as the base for this, I just replaced all needed code to be specific to phpBB

This is very beta - Please make any edits to this code to make it better. I probably will not keep the code curent, so please, take control.

Installation
This is an extension for mediawiki, but requires very small edit to phpbb core files to make it work. Nothning that will hurt phpbb at all, and will be completely compatable with any other mods you have.

Because both mediawiki and phpbb have a "user" class they want to fight. So we tell phpbb that when it is being used by mediawiki that we call the class phpbb_user and not user. I am extending the class here so we dont have to make a second copy of the entire user class

in common.php
find

replace with

In includes/session.php
find

replace with

LocalSettings.php
Place the following lines in your LocalSettings.php file: This includes the plugin, allows for user creation when needed and disables login / out of the wiki by normal means

CHANGE THIS FOR YOUR SITE $wgPhpbbSSO_Forum_Location - This needs to be the location of your forum root folder from your wiki.

The default for $wgPhpbbSSO_Forum_Location (./../forum/) works if your site is setup like so
 * example.com/forum
 * example.com/wiki

Source Files
Create a folder in your mediawiki extensions folder called phpbSSO and save these 2 files in there ( phpbSSO.php and phpbb.php )

phpbSSO.php
Note: Using this extension sets $wgMinimalPasswordLength to 1.

Using it in your skin
You probably want to change the login/register / logout links to work with the system.

This is how I did this for my wiki.

Replace the current code with the the following code (or something similar) In the skin php file where the personal links are. - In vector they are located in function renderNavigation under case 'PERSONAL':

This also adds a line so a user can see if they have any forum messages from the wiki. I changed the words "user preferences" to "wiki preferences" so it is not confusing to users.

Make sure to set the $forumURL to your forum address.

How It Works
So... This little guy, what he does is: When a user comes to the wiki, it checks to see if the user is currently logged into the forum. If not, nothing happens. If so, he then looks to see if the user is logged into the wiki. If the user is, then everything is good. If the user is not, he takes the session data from phpbb and logs the user in automatically to the wiki. If there is no such user on the wiki, he creates the user.

Cookies
If the user has cookies turned off, they will probably find themselves in an endless redirection loop.

Backups
If your backups don't work, try setting the REMOTE_USER environment variable manually: