Extension:Phpbb Single Sign-On

This is a single sign-on extension for MediaWiki and phpBB3. 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:Auth_remoteuser. 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 current, so please take control.

Installation
This is an extension for MediaWiki, but requires a very small edit to phpBB core files to make it work. Nothing that will hurt phpBB at all, and will be completely compatible with any other mods you have.

Because both MediaWiki and phpBB have a User class they will conflict. 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 don't have to make a second copy of the entire User class.

In &lt;forum directory&gt;/common.php
find replace with

In &lt;wiki directory&gt;/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

New Files
Create a folder in your MediaWiki extensions folder called phpbSSO and save the following two files in there as phpbSSO.php and phpbb.php.

Using it in your MediaWiki 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.

In Mediawiki 1.18> It is necessary to replace on

It may be necessary to define the 'wiki preferences' link. Updating for your site, replace with

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: