Commit 70781fd8 authored by Donal McMullan's avatar Donal McMullan

Improvments to error reporting for incoming SSO users

parent 9ddd43ec
......@@ -14,7 +14,6 @@
define('INTERNAL', 1);
define('PUBLIC', 1);
define('XMLRPC', 1);
......@@ -39,11 +38,24 @@ $remotewwwroot = param_variable('idp');
$wantsurl = param_variable('wantsurl', '/');
$institution = new Institution();
$institution->findByWwwroot($remotewwwroot);
try {
$institution->findByWwwroot($remotewwwroot);
} catch (ParamOutOfRangeException $e) {
throw new ParameterException(get_string('errnoxmlrcpwwwroot','auth'). htmlentities($remotewwwroot, ENT_QUOTES, 'UTF-8'));
}
$instances = auth_get_auth_instances_for_wwwroot($remotewwwroot);
if (empty($instances)) {
throw new ParameterException(get_string('errnoauthinstances','auth'). htmlentities($remotewwwroot, ENT_QUOTES, 'UTF-8'));
}
$rpcconfigured = false;
foreach($instances as $instance) {
if ($instance->authname == 'xmlrpc') {
$rpcconfigured = true;
try {
$auth = new AuthXmlrpc($instance->id);
$res = $auth->request_user_authorise($token, $remotewwwroot);
......@@ -51,13 +63,23 @@ foreach($instances as $instance) {
continue;
// we don't care
}
if ($res instanceof User) {
if ($res == true) {
break;
}
}
}
// confirm the MNET session
// redirect
redirect(get_config('wwwroot') . $wantsurl);
if ($res == true) {
// Everything's ok - we have an authenticated User object
// confirm the MNET session
// redirect
redirect(get_config('wwwroot') . $wantsurl);
// Redirect exits
}
if ($rpcconfigured === false) {
throw new UserNotFoundException(get_string('errnoxmlrcpinstances','auth').htmlentities($remotewwwroot, ENT_QUOTES, 'UTF-8'));
} else {
throw new UserNotFoundException(get_string('errnoxmlrcpuser','auth'));
}
?>
......@@ -54,4 +54,9 @@ $string['wessoout'] = 'We SSO out';
$string['theyssoin'] = 'They SSO in';
$string['application'] = 'Application';
$string['cantretrievekey'] = 'An error occurred while retrieving the public key from the remote server.<br>Please ensure that the Application and WWW Root fields are correct, and that networking is enabled on the remote host.';
$string['errnoauthinstances'] = 'We don\'t seem to have any authentication plugin instances configured for the host at ';
$string['errnoxmlrcpinstances'] = 'We don\'t seem to have any XMLRPC authentication plugin instances configured for the host at ';
$string['errnoxmlrcpwwwroot'] = 'We don\'t have a record for any host at ';
$string['errnoxmlrcpuser'] = 'We were unable to authenticate you. Please ask your Mahara administrator to check Mahara\'s authentication plugin settings, and to check that either a user record exists for you on this Mahara, or that Mahara is configured to create new records for users from your Moodle.';
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment