mirror of
https://github.com/moodle/moodle.git
synced 2025-04-29 13:03:11 +02:00
Merge branch 'MDL-58400-master' of git://github.com/junpataleta/moodle
This commit is contained in:
commit
f59c43a0fa
@ -153,6 +153,14 @@ class api {
|
||||
$settings['compactlogourl'] = $compactlogourl->out(false);
|
||||
}
|
||||
|
||||
// Identity providers.
|
||||
$authsequence = get_enabled_auth_plugins(true);
|
||||
$identityproviders = \auth_plugin_base::get_identity_providers($authsequence);
|
||||
$identityprovidersdata = \auth_plugin_base::prepare_identity_providers_for_output($identityproviders, $OUTPUT);
|
||||
if (!empty($identityprovidersdata)) {
|
||||
$settings['identityproviders'] = $identityprovidersdata;
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,16 @@ class external extends external_api {
|
||||
'launchurl' => new external_value(PARAM_URL, 'SSO login launch URL. Empty if it won\'t be used.', VALUE_OPTIONAL),
|
||||
'mobilecssurl' => new external_value(PARAM_URL, 'Mobile custom CSS theme', VALUE_OPTIONAL),
|
||||
'tool_mobile_disabledfeatures' => new external_value(PARAM_RAW, 'Disabled features in the app', VALUE_OPTIONAL),
|
||||
'identityproviders' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'name' => new external_value(PARAM_TEXT, 'The identity provider name.'),
|
||||
'iconurl' => new external_value(PARAM_URL, 'The icon URL for the provider.'),
|
||||
'url' => new external_value(PARAM_URL, 'The URL of the provider.'),
|
||||
)
|
||||
),
|
||||
'Identity providers', VALUE_OPTIONAL
|
||||
),
|
||||
'warnings' => new external_warnings(),
|
||||
)
|
||||
);
|
||||
|
@ -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
|
||||
|
@ -4,4 +4,5 @@ Information provided here is intended especially for developers.
|
||||
=== 3.3 ===
|
||||
|
||||
* External function tool_mobile::get_public_config now returns the mobilecssurl field (Mobile custom CSS theme).
|
||||
* External function tool_mobile::get_public_config now returns the identityproviders field (list of external identity providers).
|
||||
|
||||
|
@ -103,12 +103,7 @@ class login implements renderable, templatable {
|
||||
}
|
||||
|
||||
// Identity providers.
|
||||
$identityproviders = [];
|
||||
foreach ($authsequence as $authname) {
|
||||
$authplugin = get_auth_plugin($authname);
|
||||
$identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($SESSION->wantsurl));
|
||||
}
|
||||
$this->identityproviders = $identityproviders;
|
||||
$this->identityproviders = \auth_plugin_base::get_identity_providers($authsequence);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,21 +116,8 @@ class login implements renderable, templatable {
|
||||
}
|
||||
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $CFG;
|
||||
|
||||
$identityproviders = array_map(function($idp) use ($output) {
|
||||
|
||||
if (!empty($idp['icon'])) {
|
||||
$idp['iconurl'] = $output->pix_url($idp['icon']->key, $idp['icon']->component);
|
||||
} else if ($idp['iconurl'] instanceof moodle_url) {
|
||||
$idp['iconurl'] = $idp['iconurl']->out(false);
|
||||
}
|
||||
unset($idp['icon']);
|
||||
if ($idp['url'] instanceof moodle_url) {
|
||||
$idp['url'] = $idp['url']->out(false);
|
||||
}
|
||||
return $idp;
|
||||
}, $this->identityproviders);
|
||||
$identityproviders = \auth_plugin_base::prepare_identity_providers_for_output($this->identityproviders, $output);
|
||||
|
||||
$data = new stdClass();
|
||||
$data->autofocusform = $this->autofocusform;
|
||||
|
@ -610,6 +610,50 @@ class auth_plugin_base {
|
||||
*/
|
||||
public function postlogout_hook($user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of enabled identity providers.
|
||||
*
|
||||
* Each identity provider data contains the keys 'url' (string), 'name' (string) and 'icon' (pix_icon).
|
||||
*
|
||||
* @param array $authsequence site's auth sequence (list of auth plugins ordered)
|
||||
* @return array an array of enabled identity providers
|
||||
*/
|
||||
public static function get_identity_providers($authsequence) {
|
||||
global $SESSION;
|
||||
|
||||
$identityproviders = [];
|
||||
foreach ($authsequence as $authname) {
|
||||
$authplugin = get_auth_plugin($authname);
|
||||
$wantsurl = (isset($SESSION->wantsurl)) ? $SESSION->wantsurl : '';
|
||||
$identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($wantsurl));
|
||||
}
|
||||
return $identityproviders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a list of identity providers for output.
|
||||
*
|
||||
* @param array $identityproviders
|
||||
* @param renderer_base $output
|
||||
* @return array the identity providers ready for output
|
||||
*/
|
||||
public static function prepare_identity_providers_for_output($identityproviders, renderer_base $output) {
|
||||
$data = [];
|
||||
foreach ($identityproviders as $idp) {
|
||||
if (!empty($idp['icon'])) {
|
||||
$idp['iconurl'] = $output->image_url($idp['icon']->key, $idp['icon']->component);
|
||||
} else if ($idp['iconurl'] instanceof moodle_url) {
|
||||
$idp['iconurl'] = $idp['iconurl']->out(false);
|
||||
}
|
||||
unset($idp['icon']);
|
||||
if ($idp['url'] instanceof moodle_url) {
|
||||
$idp['url'] = $idp['url']->out(false);
|
||||
}
|
||||
$data[] = $idp;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1002,4 +1046,4 @@ function display_auth_lock_options($settings, $auth, $userfields, $helptext, $ma
|
||||
get_string('auth_fieldlock', 'auth'), '', 'unlocked', $lockoptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ information provided here is intended especially for developers.
|
||||
* Webservices core_course_search_courses and core_course_get_courses_by_field will always return the sortorder field.
|
||||
* core_course_external::get_activities_overview has been deprecated. Please do not call this function any more.
|
||||
* Changed the pix mustache template helper to accept context variables for the key, component and alt text.
|
||||
* New auth_plugin_base helper methods:
|
||||
- get_identity_providers() - Retrieves available auth identity providers.
|
||||
- prepare_identity_providers_for_output() - Prepares auth identity provider data for output (e.g. to templates, WS, etc.).
|
||||
|
||||
=== 3.2 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user