Extension:SMF Auth Integration
|SMF Auth Integration
Release status: stable
|Implementation||User identity, User activity|
|Description||Authenticate users from SMF.|
|Author(s)||Ryan Wagoner (rsw686talk)|
|Latest version||1.13 (2008-04-15)|
|MediaWiki||1.11.1 - 1.12.0 (1.14)|
|License||No license specified|
|Translate the SMF Auth Integration extension if it is available at translatewiki.net|
|Check usage and version matrix.|
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.
- Download the extension and place the it in the wiki/extensions/ folder.
- Add the code below to the bottom of LocalSettings.php and customize as needed.
- 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:
// $wgHooks['AutoAuthenticate'] = 'AutoAuthenticateSMF'; //original line $wgHooks['UserLoadFromSession'] = 'AutoAuthenticateSMF'; //fixed line
- For MediaWiki v1.19, you will also need to change $user->setupSession(); to wfSetupSession(); in Auth_SMF.php
- I had to apply these changes as well
# This requires a user be logged into the wiki to make changes. $wgGroupPermissions['*']['edit'] = false; // MediaWiki Setting # If you experience the issue where you appear to be logged in # even though you are logged out then disable the page cache. #$wgEnableParserCache = false; #$wgCachePages = false; # SMF Authentication # To get started you only need to configure wgSMFPath and wgSMFVersion. # The rest of the settings are optional for advanced features. # Relative path to the forum directory from the wiki # Do not put a trailing / # Example: /public_html/forum and /public_html/wiki -> ../forum $wgSMFPath = "../forum"; # Set to the version of SMF you are using. $wgSMFVersion = "1.1"; #$wgSMFVersion = "2.0"; # Use SMF's login system to automatically log you in/out of the wiki # This will only work if you are using SMF database sessions (default). # Make sure "Use database driven sessions" is checked in the # SMF Admin -> Server Settings -> Feature Configuration section # NOTE: Make sure to configure the wgCookeDomain below #$wgSMFLogin = true; # Make "Enable local storage of cookies" is unchecked in the # SMF Admin -> Server Settings -> Feature Configuration section # www.domain.org/wiki and www.domain.org/forums -> www.domain.org # wiki.domain.org and forums.doman.org -> .domain.org #$wgCookieDomain = 'www.domain.org'; #$wgCookiePath = '/'; // Optional, defaults to '/' #$wgCookieSecure = false; // Optional, only change on scheme mismatch # Require members to be a part of this SMF group(s) to login # NOTE: Members of the SMF Administrator group are always able to login #$wgSMFGroupName = 'Wiki Editor'; #$wgSMFGroupName = array('Wiki Editor', 'Global Moderator'); # Grant members of this SMF group(s) wiki sysop privileges # NOTE: These members must be able to login to the wiki #$wgSMFAdminGroupName = 'Wiki Admin'; #$wgSMFAdminGroupName = array('Wiki Admin', 'Global Moderator'); # Load up the extension require_once "$IP/extensions/Auth_SMF.php"; $wgAuth = new Auth_SMF();
- 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:
// Convert to wiki standards FIND: $username = ucfirst(str_replace('_', ' ', $user_settings[$smf_map['member_name']])); // Convert square brackets to dashes. ADD: $username = str_replace('[','-',$username); ADD: $username = str_replace(']','-',$username);
- 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.
- Keep the connection to the database open.
- Fix segfault caused by logging out an already logged out user when wgSMFLogin is enabled.
- Don't allow banned or unactivated users to log on when wgSMFLogin is enabled.
- Don't allow partially banned users to log on.
- Enable the register redirection hook when wgSMFLogin is enabled.
- Enable support for post based groups. Reported by Slack on SMF.
- 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.
- Check for SMF administrator by ID instead of name. Reported by ecpcorran on SMF.
- Provide error message when SMF group name is invalid.
- Fix login/logout redirection with new browser session when wgSMFLogin is enabled.
- 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.
- Correctly setup session when wgSMFLogin is enabled. Reported by Slack on SMF.
- Update email and display name changes when wgSMFLogin is enabled.
- 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.
- Added support for SMF 2.0 with wgSMFVersion
- 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.
- Initial release