Add some logging and an ominous warning :-)
This commit is contained in:
parent
810cc7ef9c
commit
d8ef5c36ac
1 changed files with 97 additions and 88 deletions
|
@ -14,7 +14,11 @@
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9");
|
curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9");
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode($username)."&user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login");
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode($username)."&user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login");
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
|
||||||
|
# WARNING: Never leave this on in production, as it will cause
|
||||||
|
# plaintext passwords to show up in error logs.
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||||
|
|
||||||
# The following two lines need to be enabled when using a test FAS
|
# The following two lines need to be enabled when using a test FAS
|
||||||
# with an invalid cert. Otherwise they should be commented (or
|
# with an invalid cert. Otherwise they should be commented (or
|
||||||
# set to True) for security.
|
# set to True) for security.
|
||||||
|
@ -23,15 +27,20 @@
|
||||||
$response = json_decode(curl_exec($ch), true);
|
$response = json_decode(curl_exec($ch), true);
|
||||||
curl_close ($ch);
|
curl_close ($ch);
|
||||||
|
|
||||||
if (!isset($response["success"])) return false;
|
if (!isset($response["success"])) {
|
||||||
|
fwrite(STDERR, "FAS auth failed for $username: incorrect username or password\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$groups = $response["person"]["approved_memberships"];
|
$groups = $response["person"]["approved_memberships"];
|
||||||
|
|
||||||
for ($i = 0, $cnt = count($groups); $i < $cnt; $i++) {
|
for ($i = 0, $cnt = count($groups); $i < $cnt; $i++) {
|
||||||
if ($groups[$i]["name"] == "cla_done") {
|
if ($groups[$i]["name"] == "cla_done") {
|
||||||
|
fwrite(STDERR, "FAS auth succeeded for $username\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fwrite(STDERR, "FAS auth failed for $username: insufficient group membership\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +118,7 @@ $wgExtensionCredits['other'][] = array(
|
||||||
'name' => 'Auth_FAS',
|
'name' => 'Auth_FAS',
|
||||||
'version' => '0.9.1',
|
'version' => '0.9.1',
|
||||||
'author' => 'Nigel Jones',
|
'author' => 'Nigel Jones',
|
||||||
'description' => 'Authorisation plugin allowing login with FAS2 accounts'#,
|
'description' => 'Authorisation plugin allowing login with FAS2 accounts'
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue