CentralAuth

From Linkwiki
tbd @

Background

Extension:CentralAuth is not really easy to install and update, thus we document our configuration at Wiki Aventurica here.

Do note that database schema updates for CentralAuth are not done automatically.

Source code

########################################
# Änderungen der Standardeinstellungeh #
########################################

$wgVirtualDomainsMapping['virtual-centralauth'] = [ 'db' => 'centralauth' ];

# Existing unattached accounts will be automatically migrated if possible at first login. Any new account creations will be required to attach.
$wgCentralAuthAutoMigrate = true;

# Existing unattached accounts where no global account exists will be compared to see if a merge can be made based on passwords and emails with no clashes (all accounts merge).
$wgCentralAuthAutoMigrateNonGlobalAccounts = true;

# Remaining accounts which have not been attached will be forbidden from logging in until they are resolved.
$wgCentralAuthStrict = true;

# Global session and token cookies will be set alongside the per-wiki session and login tokens when users log in with a global account. This allows other wikis on the same domain to transparently log them in.
$wgCentralAuthCookies = true;

# Domain to set global cookies for.
$wgCentralAuthCookieDomain = '.wiki-aventurica.de';

# TODO Funktion wurde anscheinen aus CentralAuth entfernt, vermutlich weil irgendjemand entschieden hat, dass Extension:UserMerge jetzt nicht mehr unterstützt wird
#$wgCentralAuthEnableUserMerge = true; //enable the global user merge tool

###########################
# Definition der Wikifarm #
###########################

// You can't just set wgConf values to the globals defined in Setup.php for your
// local wiki, because it hasn't run yet.  You could hard-code $wgConf settings
// here, but instead we set the wgConf values in a hook that runs later.

$wgLocalDatabases = [
    'dewa',
    'enwa',
    'frwa',
    'itwa',
    'nlwa',
    'ruwa',
];
#$wgConf->localVHosts = [ 'localhost' ];
$wgConf = new SiteConfiguration;
$wgConf->suffixes = [ 'wa' ];
$wgConf->wikis = $wgLocalDatabases;
$wgConf->settings = [
    'wgServer' => [
        #'default' => 'http://localhost',
        'dewa' => 'https://de.wiki-aventurica.de',
        'enwa' => 'https://en.wiki-aventurica.de',
        'frwa' => 'https://fr.wiki-aventurica.de',
        'itwa' => 'https://it.wiki-aventurica.de',
        'nlwa' => 'https://nl.wiki-aventurica.de',
        'ruwa' => 'https://ru.wiki-aventurica.de',
    ],
    'wgScriptPath' => [
        'dewa' => '/de',
        'enwa' => '/en',
        'frwa' => '/fr',
        'itwa' => '/it',
        'nlwa' => '/nl',
        'ruwa' => '/ru',
    ],
    'wgArticlePath' => [
        'default' => '/wiki/$1',
    ],
    'wgSitename' => [
        'default' => 'Wiki Aventurica',
    ],
    'wgLanguageCode' => [
        'default' => '$lang',
    ],
    'wgLocalInterwiki' => [
        'default' => 'w$lang',
    ],
];

$wgConf->siteParamsCallback = 'efGetSiteParams';
$wgConf->extractAllGlobals( $wgDBname );

function efGetSiteParams( $conf, $wiki ) {
    $site = null;
    $lang = null;
    foreach( $conf->suffixes as $suffix ) {
        if ( substr( $wiki, -strlen( $suffix ) ) === $suffix ) {
            $site = $suffix;
            $lang = substr( $wiki, 0, -strlen( $suffix ) );
            break;
        }
    }
    return [
        'suffix' => $site,
        'lang' => $lang,
        'params' => [
            'lang' => $lang,
            'site' => $site,
            'wiki' => $wiki,
        ],
        'tags' => [],
    ];
}

Creating a wiki farm with CentralAuth

I made the following notes when I was configuring the WA wiki farm (2016); possibly some notes are obsolete.


Folge med:Manual:Wiki family#Multiple wikis sharing common resources:

  • Unterordner pro Sprachversion, dazu "shared" für gemeinsame Dateien; Dateien im Grundordner der MediaWiki-Installation müssen sowohl in den Sprachversionen als auch in shared vorhanden sein
  • Sprachordner bekommen "cache", "images", und "mw-config"-Ordner sowie Symbolic Links auf die entsprechenden Ordner in shared:
ln -s ../shared/docs/ docs
ln -s ../shared/extensions/ extensions
ln -s ../shared/includes/ includes
ln -s ../shared/languages/ languages
ln -s ../shared/maintenance/ maintenance
ln -s ../shared/resources/ resources
ln -s ../shared/serialized/ serialized
ln -s ../shared/skins/ skins
ln -s ../shared/tests/ tests
ln -s ../shared/vendor/ vendor
  • shared bekommt eine localsettings mit folgendem Inhalt (... ruft also einfach nur eine der anderen localsettings auf, wenn die Umgebungsvariable WIKI passend gesetzt wurde):
require_once("../".$_SERVER["WIKI"]."/LocalSettings.php");
  • Wartungsskripte können dann folgendermaßen aufgerufen werden (wenn man in der Konsole in einem der Sprachunterordner ist! Es ist dann auch egal, in welchem)
WIKI=en php maintenance/update.php
  • Jobs künftig per cron laufen lassen?
$wgJobRunRate = 0;
  • Hochladen-Funktion der anderen auf de umlegen:
$wgUploadNavigationUrl = "http://pool.yourwiki.org/index.php/Special:Upload";
  • Bilder aus de in den anderen nutzen:
$wgUseSharedUploads = true;
$wgSharedUploadPath = 'http://pool.yourwiki.org/images';
$wgSharedUploadDirectory = '/(LOCALPATH)/POOL-FOLDER/images/';
$wgHashedSharedUploadDirectory = true;
$wgFetchCommonsDescriptions = true;
$wgSharedUploadDBname = 'pool';  # DB-Name of PoolWiki
$wgSharedUploadDBprefix = 'wiki_'; # Table name prefix for PoolWiki
$wgRepositoryBaseUrl = "http://pool.yourwiki.org/index.php/Image:";

Dazu noch Extension:CentralAuth installieren - die nötigen Schritte aus der Seite der Extension und dem Walkthrough zusammenstückeln

  • Datenbank "centralauth" anlegen
  • Datenbanktabellen und Indices anlegen: per Konsole in den Ordner der Extension wechseln und eingeben:
mysql -u wiki -p
USE centralauth;
SOURCE central-auth.sql
  • spoofuser-Tabelle von der de-Datenbank übertragen:
mysqldump -u wiki -p wade spoofuser > /tmp/spoofuser.temp
mysql -u wiki -p centralauth < /tmp/spoofuser.temp
  • centralauth in den localsettings eintragen und konfigurieren
  • Nutzer aus de migrieren (Konsole muss weiterhin im Ordner der Extension sein):
php maintenance/migratePass0.php
php maintenance/migratePass1.php
  • In de einen "Steward" ernennen und dann migrieren (lokaler Steward-Status kann danach wieder entzogen werden):
php maintenance/migrateStewards.php
  • Jetzt noch dem Steward-Status in der Centralauth-Datenbank Rechte zuweisen:
mysql -u wiki -p
USE centralauth;
INSERT INTO global_group_permissions (ggp_group,ggp_permission) VALUES ('steward','globalgrouppermissions'),('steward','globalgroupmembership');