Extension:SMF Auth Integration

Overview
This extension integrates MediaWiki with SMF's members table. It has been tested on MediaWiki 1.11.1 through 1.12.0 and is compatible with SMF versions 1.1.x and 2.0.

To get started you only need to configure the relative path to your SMF forum. In the default configuration the wiki login is separate from the forum. You can enable auto authentication by configuring the required settings.

If you decide to use auto authentication, when you click login / logout, the wiki will redirect you to the SMF page and then back to the wiki. For this to work you must be using SMF database sessions (default setting). You also need to ensure local storage of cookies is disabled in SMF.

Another feature is the restriction of editing to one or more SMF member groups. Keep in mind that SMF administrators are always allowed to edit. You can also add one or more member groups to by MediaWiki sysops.

Installation
//                     $wgHooks['AutoAuthenticate'][] = 'AutoAuthenticateSMF'; //original line $wgHooks['UserLoadFromSession'][] = 'AutoAuthenticateSMF'; //fixed line
 * 1) Download the extension and place the it in the wiki/extensions/ folder.
 * 2) Add the code below to the bottom of LocalSettings.php and customize as needed.
 * 3) Since the release of MediaWiki v1.13, this bridge still works for SMF v1.1.x and 2.0.  However, in the Auth_SMF.php, you will need to search for "AutoAuthenticate", and replace it with "UserLoadFromSession" (just one occurrence).  This applies if you wish to use the auto-authentication hook for users with SMF accounts.  AutoAuthenticate has been deprecated since MediaWiki v1.13, and replaced with UserLoadFromSession, specifically make this change:
 * 1) For MediaWiki v1.19, you will also need to change $user->setupSession; to wfSetupSession; in Auth_SMF.php

Known Issues

 * The wiki converts underscores in usernames to spaces. For example john_doe becomes John doe. To work around this we check for both cases and use the first registered SMF user. You will need to change the usernames of the later registered user.


 * When wgSMFLogin is disabled if you register a new account from the wiki you will not be redirected back to the wiki. SMF does not have support for this in their code.


 * If the SMF memberName has any square brackets in it, it will cause "MediaWiki internal error. Exception caught inside exception handler". To work around this after line 276 of Auth_SMF.php I added:

Change Log
 1.13 
 * Move hook initialization into class to prevent potential errors.
 * Fix require errors when running wiki maintenance scripts.
 * Cache the groups the user is a member of to save queries.
 * Combine the group name lookups into one query.

 1.12 
 * Keep the connection to the database open.
 * Fix segfault caused by logging out an already logged out user when wgSMFLogin is enabled.

 1.11 
 * Don't allow banned or unactivated users to log on when wgSMFLogin is enabled.
 * Don't allow partially banned users to log on.

 1.10 
 * Enable the register redirection hook when wgSMFLogin is enabled.
 * Enable support for post based groups. Reported by Slack on SMF.

 1.9 
 * When logging in/out send them back to the page they were on. Reported by ecpcorran on SMF.
 * Redirect create account to the SMF register page when wgSMFLogin is disabled.
 * Fix issue with underscore in username when sgSMFLogin is enabled.

 1.8 
 * Check for SMF administrator by ID instead of name. Reported by ecpcorran on SMF.

 1.7 
 * Provide error message when SMF group name is invalid.
 * Fix login/logout redirection with new browser session when wgSMFLogin is enabled.

 1.6 
 * Use existing wgAuth instead of creating a new class.
 * Clarify and clean up source code commenting.
 * Use set and get for user class instead of directly assigning variables.
 * Fix bug introduced by change password for new members when wgSMFLogin is disabled.
 * Fix admin check error for usernames with space or underscore when wgSMFLogin is disabled.
 * Load user from database only if no previous session when sgSMFLogin is enabled.
 * Alert for unexisiting username with space or underscore when wgSMFLogin is disabled.

 1.5 
 * Correctly setup session when wgSMFLogin is enabled. Reported by Slack on SMF.

 1.4 
 * Update email and display name changes when wgSMFLogin is enabled.

 1.3 
 * Authenticate emails for new wiki users when wgSMFLogin is enabled.
 * Enable passwords to be changed via the wiki when wgSMFLogin is disabled.
 * Don't allow banned or unactivated users to log on when wgSMFLogin is disabled.

 1.2 
 * Added support for SMF 2.0 with wgSMFVersion

 1.1 
 * Attempt to work around underscores in usernames when wgSMFLogin is disabled.
 * Allow an array of multiple groups to be used for wgSMFGroupName.
 * Add wgSMFAdminGroupName to define groups that should be granted wiki sysop rights.

 1.0 
 * Initial release