I've been using the great GoogleAppsAuthentification extension for mediawiki to allow my users to log in with their Google Apps account. We recently added another domain to our Google Apps and I'd like to offer those users the option to log into our wiki with their Google Apps Domain.
Out of the box, this isn't possible with the extension, however it seems pretty trivial to add multiple domain support.
The idea is to prompt the user with a dropdown list of available domains prior to executing the redirect to Google's login screen.
My knowledge of the mediawiki API is rather limited and I could use some pointers.
the extension hooks into the UserLoadFromSession hook, which is called before the UserLoginForm hook. I would have to add code to this function to prompt the user for a domain, and return to this function, passing the selected domain to getGoogleAccount()
// in LocalSettings.py
$wgDefaultUserOptions['GoogleAppsDomainList'] = array("domain.com", "otherdomain.com");
// in GoogleAppsAuthentication.php
function fnGoogleAppsAuthenticateHook($user, &$result){
global $IP, $wgLanguageCode, $wgRequest, $wgOut, $wgDefaultUserOptions;
if (isset($_REQUEST["title"])){
$lg = Language::factory($wgLanguageCode);
if ($_REQUEST["title"] == $lg->specialPage("Userlogin")){
// this is where we need to add the prompt
// that asks the user which domain to chose
$domain = getDomainFromUser($wgDefaultUserOptions['GoogleAppsDomainList'])
// Setup for a web request
require_once("$IP/includes/WebStart.php");
// Here we do our stuff
$googleAccount = getGoogleAccount('title=' . $_REQUEST["title"], $domain);
// whole bunch of code here that won't be affected by our change
...
// end whole bunch of code that won't be affected by our change
} else if ($_REQUEST["title"] == $lg->specialPage("Userlogout")) {
session_unset();
// Logout
$user->logout();
}
}
// Back to MediaWiki home after login
return true;
}
function getDomainFromUser($domainList) {
// render page with dropdown containing domains in $domainList
// get selected dropdown on page submit
// return selected domain
}
I need some help with the getDomainFromUser() function. I don't know how to redirect to a new page that shows a dropdown menu populated by an array defined in the LocalSettings.py and return the selected value back to the fnGoogleAppsAuthenticateHook function.
Any help would be sincerely appreciated. I believe a lot more people can benefit from this additional functionality added to this extension.