MDL-58400 tool_mobile: Support direct launch of OAuth SSO process

This commit is contained in:
Juan Leyva
2017-04-10 11:12:29 +08:00
committed by Jun Pataleta
parent a67e3bda2e
commit e352f30699
+11
View File
@@ -32,12 +32,23 @@ $serviceshortname = required_param('service', PARAM_ALPHANUMEXT);
$passport = required_param('passport', PARAM_RAW); // Passport send from the app to validate the response URL.
$urlscheme = optional_param('urlscheme', 'moodlemobile', PARAM_NOTAGS); // The URL scheme the app supports.
$confirmed = optional_param('confirmed', false, PARAM_BOOL); // If we are being redirected after user confirmation.
$oauthsso = optional_param('oauthsso', 0, PARAM_INT); // Id of the OpenID issuer (for OAuth direct SSO).
// Check web services enabled.
if (!$CFG->enablewebservices) {
throw new moodle_exception('enablewsdescription', 'webservice');
}
// We have been requested to start a SSO process via OpenID.
if (!empty($oauthsso) && is_enabled_auth('oauth2')) {
$wantsurl = new moodle_url('/admin/tool/mobile/launch.php',
array('service' => $serviceshortname, 'passport' => $passport, 'urlscheme' => $urlscheme, 'confirmed' => $confirmed));
$oauthurl = new moodle_url('/auth/oauth2/login.php',
array('id' => $oauthsso, 'sesskey' => sesskey(), 'wantsurl' => $wantsurl));
header('Location: ' . $oauthurl->out(false));
die;
}
// Check if the plugin is properly configured.
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
if (empty($SESSION->justloggedin) and