Drupal Mediawiki

From Jon's Wiki

Drupal can act as master authentication for a slave Mediawiki installation by using the AuthDrupal extension. There are several steps involved. More detailed instructions over at the AuthDrupal site.

  1. Check you have php5-mcrypt installed.
  2. Download the AuthDrupal Mediawiki extension.
  3. Untar to extensions/AuthDrupal directory under the Mediawiki installation.
  4. Edit extensions/AuthDrupal/crypto.php and change $key = 'something site-unique here'
  5. Move Mediawiki.* and copy crypto.php to modules/mediawiki directory under the Drupal installation.
  6. Add the Mediawiki details to the Drupal module (see Drupal Settings below)
  7. Edit LocalSettings.php to configure AuthDrupal (see Mediawiki Settings below)
  8. Edit the Login message by editing the MediaWiki:Whitelistedittext article. Use $wgAuthDrupal_LoginURL as the URL:
Please <span class="plainlinks">[http://mydomain.com/user log in]</span> first.

Mod Rewrite

<IfModule mod_rewrite.c>
 RewriteRule ^/Special:Userlogin https://%{SERVER_NAME}/login/ [R,L]
 RewriteCond %{REQUEST_URI} ^/index.php$
 RewriteCond %{QUERY_STRING} ^title=Special:Userlogin
 RewriteCond %{REQUEST_METHOD} ^GET$
 RewriteRule ^(.*)$ /login/ [R,L]
</IfModule>

Drupal Settings

Edit the top of Mediawiki.module to add your Mediawiki instance. Use the same cookie domain as the one set in LocalSettings.php

$GLOBALS['wgAuthDrupal_wiki_settings'] = array(
       array(
           'wgCookieDomain'    => '.yourdomain.com',
           'wgDBname'          => 'mediawiki_database',
           'wgDBprefix'        => "",
           // If you set $wgCookiePath in wiki/LocalSettings, set it to
           // the same thing here; otherwise, leave as '/'
           'wgCookiePath'      => '/'
       )
   );

Mediawiki Settings

Add the following to the Mediawiki LocalSettings.php file and adjust:

###################################################################### 
# User authentication via Drupal using AuthDrupal

$wgCookieDomain = '.yourdomain.com';

# Point Mediawiki to the Drupal database
$wgAuthDrupal_UseExtDatabase = true;
$wgAuthDrupal_MySQL_Host     = 'mysql_host';
$wgAuthDrupal_MySQL_Username = 'drupal_user';
$wgAuthDrupal_MySQL_Password = 'password';
$wgAuthDrupal_MySQL_Database = 'drupal_database';
$wgAuthDrupal_TablePrefix      = "";
$wgAuthDrupal_UserTable     = 'users';

# If you use Drupal's user profile module, you can tell Auth Module to
# grab their full name into their Mediawiki user profile.
$wgAuthDrupal_GetRealNames = false;
# $wgAuthDrupal_RealNames_fields_table; // set if not 'profile_fields'
# $wgAuthDrupal_RealNames_values_table; // set if not 'profile_values'
# $wgAuthDrupal_RealNames_first_name_field; // set if not 'profile_first_name'
# $wgAuthDrupal_RealNames_last_name_field;  // set if not 'profile_last_name'

# replace Mediawiki login/logout pages
$wgAuthDrupal_ReplaceLogin = true;
$wgAuthDrupal_LoginURL = 'http://my.drupal.site/user';
$wgAuthDrupal_LogoutURL = 'http://my.drupal.site/?q=logout';

# Add status messages to the Drupal watchdog log?
$wgAuthDrupal_LogMessages = false;

require_once 'extensions/AuthDrupal/AuthDrupal.php';
SetupAuthDrupal();

Links