diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 146990c755ebf..00cf77e725fa4 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -357,6 +357,7 @@ public static function get_autologin_key() { */ public static function get_features_list() { global $CFG; + require_once($CFG->libdir . '/authlib.php'); $general = new lang_string('general'); $mainmenu = new lang_string('mainmenu', 'tool_mobile'); @@ -366,6 +367,7 @@ public static function get_features_list() { $user = new lang_string('user'); $files = new lang_string('files'); $remoteaddons = new lang_string('remoteaddons', 'tool_mobile'); + $identityproviders = new lang_string('oauth2identityproviders', 'tool_mobile'); $availablemods = core_plugin_manager::instance()->get_plugins_of_type('mod'); $coursemodules = array(); @@ -485,6 +487,31 @@ public static function get_features_list() { $features["$remoteaddons"] = $remoteaddonslist; } + // Display OAuth 2 identity providers. + if (is_enabled_auth('oauth2')) { + $identityproviderslist = array(); + $idps = \auth_plugin_base::get_identity_providers(['oauth2']); + + foreach ($idps as $idp) { + // Only add identity providers that have an ID. + $id = isset($idp['url']) ? $idp['url']->get_param('id') : null; + if ($id != null) { + $identityproviderslist['NoDelegate_IdentityProvider_' . $id] = $idp['name']; + } + } + + if (!empty($identityproviderslist)) { + $features["$identityproviders"] = array(); + + if (count($identityproviderslist) > 1) { + // Include an option to disable them all. + $features["$identityproviders"]['NoDelegate_IdentityProviders'] = new lang_string('all'); + } + + $features["$identityproviders"] = array_merge($features["$identityproviders"], $identityproviderslist); + } + } + return $features; } diff --git a/admin/tool/mobile/lang/en/tool_mobile.php b/admin/tool/mobile/lang/en/tool_mobile.php index f9827768955b7..39430c5c235c9 100644 --- a/admin/tool/mobile/lang/en/tool_mobile.php +++ b/admin/tool/mobile/lang/en/tool_mobile.php @@ -86,6 +86,7 @@ $string['mobilefeatures'] = 'Mobile features'; $string['mobilenotificationsdisabledwarning'] = 'Mobile notifications are not enabled. They should be enabled in Notification settings.'; $string['mobilesettings'] = 'Mobile settings'; +$string['oauth2identityproviders'] = 'OAuth 2 identity providers'; $string['offlineuse'] = 'Offline use'; $string['pluginname'] = 'Moodle app tools'; $string['pluginnotenabledorconfigured'] = 'Plugin not enabled or configured.';