User:Nguyenh/BasicAutoAuth

 
A proposal to move this page to MediaWiki.org was rejected.

Purpose

edit

This MediaWiki extension automatically logs you into your wiki using the credentials provided by the web server, for example through the HTTP Basic Authentication (BasicAuth) mechanism with .htaccess / .htpasswd.

See below for a changelog.

Installation & Configuration

edit

Copy and paste the source code and save it as BasicAutoAuth.php in your MediaWiki's extension directory. If you copy the contents from the edit window, remove the <pre> and </pre> tags at the top and the bottom. Do not forget to check code and edit history to make sure the extension has not been tampered with.

In your LocalSettings.php, add the following line:

require_once( "extensions/BasicAutoAuth.php" );

Important Notes

edit
  • Should work with MediaWiki 1.9 and newer
  • MediaWiki 1.8alpha (revision 15823) up to 1.8.2 were not compatible with this extension. Please consider using a newer version where the AutoAuthenticate bug is finally fixed (revision 17069 and above, bug 6929).
  • To log on under a different wiki account, log out and immediately click login again (or go straight to the login page)
  • The extension does not automatically create a wiki account
  • The extension checks if the password provided by the web server matches the one set for the wiki account. If you do not want this, see the following section

Removing password check

edit

To disable password verification, replace the lines

        else {
            $u->loadFromDatabase();

            /* Check against supplied password */
            if ( $u  &&  $u->checkPassword( $_SERVER[ 'PHP_AUTH_PW' ] ) ) {
                $user = $u;
            }
        }

with these:

        else {
            $u->loadFromDatabase();
            $user = $u;
        }

Changelog

edit

0.12 (2007-01-31)

edit
  • Fix: Improper version check prohibited the extension to load on MediaWiki 1.10alpha+

0.11 (2006-10-18)

edit
  • Fix: Use User::newFromSession on newer versions of MediaWiki instead of User::loadFromSession

0.10b (2006-07-19)

edit
  • Fix: Check if User::loadFromSession returned a User object
  • Fix: Check if $wgAuth is an object

0.10a (2006-07-16)

edit
  • Fix: Function to initialize User object did not reference User object but $this