Extension:Shibboleth Authentication

Overview
Shibboleth is a Single Signon identity managment solution that's a project of Internet2. It's in use not only in many universities through the US and elsewhere but also on sites such as openidp to provide authentication to a range of applications. This extension allows mediawiki to use Shibboleth as an external authentication source.

Current Version: 1.2.2

Compatibility
This extension is designed for MediaWiki 1.7 and up. If you want to use this extension with the 1.6 branch or earlier look at bugs 5819 and 6006 and apply the SVN changes that took place.

Shibboleth Configuration
The extension requires that shibboleth be configured and set up on the web server the wiki is hosted on. Once Shibboleth is running on the web server make sure your configuration file is correctly set-up. Your IdP should be able to help you with this. The extension uses lazy sessions and a WAYF url so you'll want to verify these are setup as well. (You can actually use full sessions if you want, but the extension is designed to use lazy sessions to allow for the standard wiki auth to co-exist alongside.) You'll need to tell the extension which WAYF url to use.

The part of the configuration file (shibboleth.xml) where a WAYF url will be present is here: ...   

For lazy sessions in Apache, the following lines in your apache configuration files will do: ...  AuthType shibboleth Require shibboleth 

If you don't want lazy sessions but instead would rather require shibboleth authentication, then use: ...  AuthType shibboleth ShibRequireSession On       Require valid-user 

Download the Extension
The code for the extension is at the bottom of this page. Place it in the extensions folder, in a file called "ShibAuthPlugin.php."

Extension Configuration
Now it's time to configure and load the extension. To do that, just add the following lines to LocalSettings.php in the root of the mediawiki directory.

Most of the configuration directives are of the form: This allows you to map whatever shibboleth identifiers you chose to a variety of fields for each user as well as use the standard PHP functions to massage the data as it enters. All the Shibboleth data has been placed in the $_SERVER superglobal by the Shibboleth module and should be available. You may need to run a script like the following to determine exactly what data is available:

At the very minimum you'll need to make the following changes:
 * 1) Place the following code into the LocalSettings.php file.
 * 2) Set the WAYF url.
 * 3) Map a valid piece of Shib data for the username.
 * 4) Look over the rest of the variables and ensure that you don't want to make any more changes.

Using the Extension
The extension is designed to be fairly simple to use. Once everything is configured and Shibboleth is running a link will appear at the top right hand corner of the screen next to the normal mediawiki login link that says "login via single sign-on." Clicking this link will bounce the user to the WAYF url which will pass them to the IdP for authentication. When they come back they'll be logged in.

Adding more Metadata
If you wish to add more mappings from Mediawiki data to Shibboleth data than is available, you can simply add them in the configuration file. You just have to add the code changes in the event handler or add an extra event handler (ShibUpdateTheUser in the example).

Logout Functionality
Shibboleth currently has no good way to log people out. By default logout is disabled once people sign in through Shibboleth. Alternatively you may point logout to a url provided by your local IdP which will allow logout. If your local IdP doesn't support this and you really would like to log people out, simply create a small php script to unset the Shibboleth cookies and point people towards that, then redirect them to the standard mediawiki logout script.

Username Munging
While the extension will enforce the rule that all usernames must begin with a capital letter, it will not enforce any of the rest of mediawiki's usual rules for usernames. If your Shibboleth data will break other mediawiki username rules you should filter that out at the configuration level when $shib_UN gets set. In addition, if your shibboleth data includes sets of usernames that may only be separated by difference of upper and lower-case initial letters (Like "Nick@example.org" and "nick@example.org") then the plugin will treat these two as if they were not distinct. Again the solution is to provide additional filtering in LocalSettings.php. By default we simply use the user's e-mail addresses converting any letters to lowercase and then pass those in. (Again, the extension takes care of converting the initial letter to uppercase.)

Differences between 1.2.2 and 1.2.1

 * Compatibility fix for MW 1.13: Automatic user creation didn't work any more

Differences between 1.2.1 and 1.2.0

 * Functions renamed so they start with Shib (to prevent naming conflicts)
 * Compatibility fix for MW 1.13: the AutoAuthenticate hook has been replaced by the UserLoadFromSession hook. The extension checks the version and registers the appropriate hook.

Differences between 1.2.0 and 1.1.8
What's new in this version:
 * The configuration for this version is not backwards compatible with the previous version if $shib_map_info was set to true (search for ShibUpdateUser on this page).
 * $shib_map_info is no longer used, nor are $shib_RN and $shib_email (directly).
 * Mapping information from shibboleth to mediawiki now happens in event handlers for the ShibUpdateUser-hook instead of the updateUser-function itself.
 * A security bug was fixed that caused users to remain logged in even after closing their browser when lazy authentication is used
 * $wgCookieExpiration is made negative so when the user comes back after closing the browser, the homepage doesn't come from the per-user-cache but from the anonymous-user cache.
 * Added extensionCredits to show the plugin on the Special:Version page

Differences between 1.1.8 and 1.1.7

 * another forgotten Compatibility fix or MW 1.12

Differences between 1.1.7 and 1.1.6

 * Compatibility fixes for MW 1.12 release: Hooks return true to continue other hook processing

Differences between 1.1.6 and 1.1.5

 * Compatibility fixes for upcoming MW 1.10.0 release. (They broke the plugin again :-\)
 * Fix error in some versions of php and MW that caused the plugin to fail
 * Fix PHP notice about an undefined variable
 * When $shib_RN is not null and $shib_map_info is set to true the plugin will now display the user's name in their URLs instead of their username. This looks pretty slick, but may need to be more configurable in the future.

Differences between 1.1.5 and 1.1.4

 * Some of the cleanups in 1.1.4 blocked an untested codepath and prevented the plugin from working

Differences between 1.1.4 and 1.1.3

 * Security Fix: Namespace collisions are now handled by clobbering the old user
 * Cleanup for setting passwords, more compatible with new changes, less kludgy code as well
 * Fixed longstanding warning caused by a typo in an earlier version of the code (oops)

Differences between 1.1.3 and 1.1.2

 * Extra error handling plus compatibility fixes for mediawiki version 1.6.8 (hook patches added)

Differences between 1.1.2 and 1.1.1

 * Compatibilty fixes for 1.9

Differences between 1.1.1 and 1.1

 * Preserve compatibility with 1.0 configuration files for $shib_LoginHint

Differences between 1.1 and 1.0

 * Extra configuration options
 * shib_Https (whether the AssertionConsumerService url is at https, default is false)
 * shib_AssertionConsumerServiceURL (defaults to /Shibboleth.sso)
 * Sites that are accessed via https are redirected there after logging in using lazy authentication
 * Login Form Cleanup
 * New Contributor: Steven Langenaken

Acknowledgements
These folks have helped out by reporting issues and breakages or testing early code releases to help eliminate issues and breakages. Without them this software would have more bugs.

Bug Reporters

 * Martin Kos - Reported breakage in 1.1.4
 * Eric Jiang - Reported breakage in 1.1.1
 * Bajnokk - Reported breakage in 1.2.1
 * Dhess - Provided fix for setup_session error in 1.2.2

Testers

 * Joe Pomianek - UCSD