Extension talk:CentralAuth/Walkthrough

Add discussion
Active discussions

ErrorsEdit

Basically, I followed your instructions and can merge users, but when I try to look up global user info, I got a PHP error saying that a non-existent function was being defined. The helper said that this site-info-getting function only existed in the trunk version, however I don't know what that means.Jasper Deng 23:32, 8 February 2012 (UTC)

Sorry you're having issues. I'm making the assumption theres a bug in the current code, but actually don't know. You might want to try starting again and using the wmf deployed extension, which is usually more stable but isn't the latest, such as http://svn.wikimedia.org/svnroot/mediawiki/branches/wmf-deployment/extensions/CentralAuth/ Since I'm not a php programmer other than <?php echo "hello world"I can't really comment on the php error itself, although both a bug and running on an older version of MW could explain it. What version are you running? Good luck, Thompson.matthew 04:22, 9 February 2012 (UTC)
Using the released 1.18; I don't know what "trunk" means; the PHP error only meant that I had to "use the trunk".Jasper Deng 04:28, 9 February 2012 (UTC)

ProblemsEdit

I have everything installed but when I goto GlobalGroupPermissions and attempt to edit a group, they are all disabled. And something else I noticed, the "Set of wikis where this group is active:" part says 0 for each group. I just don't get it. Hope you can help. Thanks, Jempcorp (talk) 16:57, 29 June 2012 (UTC).

It's OK! I fixed it by modifying the extension so that it checked local rights. Then I added a wikiset and set the groups to the wikiset, then I reverted my edits of the extension and it works perfectly! :D Thanks anyway for all your help in creating that tutorial! Jempcorp (talk) 08:23, 30 June 2012 (UTC).

SuffixesEdit

Hi Matthew, thanks a lot for this great tutorial! One question though: Does "all databases have suffix wiki" mean that my databases have to be named with the suffix "_wiki" (like "english_database_wiki", "german_database_wiki"...) and can't have names like just "english_database"? Thanks + cheers, --Till Kraemer (talk) 14:21, 16 August 2012 (UTC)

That's what I did. I'll be honest, I'm not 100& sure, the CentralAuth article does say "(e.g. hypothetical databases enwiki, dewiki, frwiki, etc., pertaining to wikis belonging to the same group, all have the suffix "wiki")". Sorry for the long response. Thompson.matthew (talk) 13:34, 23 September 2012 (UTC)
Hi Thompson.matthew, thanks for your response! My databases don't have the _wiki suffix, maybe that's the reason why CentralAuth doesn't work for me. I will try it with the _wiki suffix. Thanks and cheers, --Till Kraemer (talk) 16:52, 25 September 2012 (UTC)

How to modify setup for databases not having the same suffix?Edit

First, Thanks a lot for this great walkthrough. I am trying to apply it for my wiki family. I already had the databases setup. They don't have the same suffix. Their names are like this: "planets_mwen", ""planets_mwar", ""planets_mwfr"..etc How to modify the setup to be applied for databases that don't share the same suffix, as per your walkthrough? (I know that there is another question about this back in 2012, but I am hoping that more information are now available as the other questions does not have definitive answers). Also, I followed the setup of "multiple wikis sharing the same resources (link here). Can I add the settings to the "ExtensionsSettings.php" that the wiki family documentation refer to? Are there changes in your code required to get it to work from the "ExtensionsSettings.php"? Finally, is it better to add the users to the database of the most used wiki, or the pool wiki. or a totally separate database installation? I appreciate your help. Thanks a lot.

SQLite databaseEdit

Could you create a walkthrough explaining in SQLite database? 2804:431:D701:FA4:108:D632:8F83:398C 14:59, 1 September 2019 (UTC)

Doesn't workEdit

I have setup centralauth between two wikis, and it doesn't login because it keeps thinking it's a local account or something. --ErtasVideos (talk) 09:04, 15 April 2020 (UTC)

Working example for wikifarmEdit

I thought I would share my currently working LocalSettings.php for a wikifarm of language wikis that share a single LocalSettings.php.

After some trial and error, bang this is finally working.

In my database setup, instead of using the language as a prefix and the name of the wiki as a suffix, I'm using the name of the wiki as a prefix and the language as a suffix, separated by an _ character. So I had to adust the 'efGetSiteParams' callback accordingly.

Each language wiki is set up on a language subdomain, like wikipedia. The $wikiId for each language wiki is simply the language, as detected from the subdomain, such as "en" or "es" or "it".

wfLoadExtension( 'CentralAuth' );
# General CentralAuth configuration
$wgCentralAuthCookies = true;
$wgCentralAuthDatabase = 'seminaverbi';
$wgCentralAuthAutoMigrate = true;
$wgCentralAuthAutoMigrateNonGlobalAccounts = true;
$wgCentralAuthCookieDomain = '.seminaverbi.bibleget.io';
$wgCentralAuthAutoLoginWikis = [
    # Mapping from domain name to wiki id for other wikis to automatically login into
    "https://en.seminaverbi.bibleget.io" => "seminaverbi_en",
    "https://it.seminaverbi.bibleget.io" => "seminaverbi_it",
    "https://fr.seminaverbi.bibleget.io" => "seminaverbi_fr",
    "https://de.seminaverbi.bibleget.io" => "seminaverbi_de",
    "https://es.seminaverbi.bibleget.io" => "seminaverbi_es",
    "https://pt.seminaverbi.bibleget.io" => "seminaverbi_pt"
];

# Create the local account on pageview, set false to require a local login to create it.
$wgCentralAuthCreateOnView = true;

# Activates the redirect to the "central login wiki"
$wgCentralAuthLoginWiki = 'seminaverbi_en';

# Skips the "login success" page
$wgCentralAuthSilentLogin = true;
$wgCookieSameSite = "None";
$wgUseSameSiteLegacyCookies = true;

$wgConf = new SiteConfiguration;
$wgConf->wikis = [ 'seminaverbi_en', 'seminaverbi_it', 'seminaverbi_es', 'seminaverbi_fr', 'seminaverbi_de', 'seminaverbi_pt' ];
$wgConf->localVHosts = ['localhost'];

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

$wgConf->suffixes = ["seminaverbi"];


$wgConf->settings = [
 
    'wgServer' => array(
        'default' => "https://{$wikiId}.seminaverbi.bibleget.io", //default means applied to all wikis. We want our location to be http://localhost/(wiki). If your wikis are hosted on different domains, then you would override this, but let's keep it simple
    ),
     
    'wgCanonicalServer' => array(
        'default' => "https://{$wikiId}.seminaverbi.bibleget.io",
    ),
    
    'wgScriptPath' => [
        'default' => '/w', //script path, where index.php is located
    ],
    'wgArticlePath' => [
        'default' => "/wiki/$1", //script path, where index.php is located
    ],
    'wgLanguageCode' => array( //dont change, if all wikis are english *BE careful not to alter this line if you use RegEx to replace COD with your wiki name!
        'default' => $wikiId,
    ),
     
    'wgLocalInterwiki' => [
        'default' => $wikiId,
    ],
];

$wgConf->siteParamsCallback = 'efGetSiteParams';
$wgConf->extractAllGlobals( $wgDBname );
Return to "CentralAuth/Walkthrough" page.