diff --git a/auth/oidc/classes/form/binding_username_claim.php b/auth/oidc/classes/form/binding_username_claim.php index 46ec1292a..f091ab945 100644 --- a/auth/oidc/classes/form/binding_username_claim.php +++ b/auth/oidc/classes/form/binding_username_claim.php @@ -116,7 +116,7 @@ protected function definition() { $mform->addElement( 'select', 'bindingusernameclaim', - auth_oidc_config_name_in_form('binding_username_claim'), + auth_oidc_config_name_in_form('beingusernameclaim'), $bindingusernameoptions ); $mform->setDefault('bindingusernameclaim', 'auto'); diff --git a/auth/oidc/classes/loginflow/base.php b/auth/oidc/classes/loginflow/base.php index 7dda180b8..219c6d437 100644 --- a/auth/oidc/classes/loginflow/base.php +++ b/auth/oidc/classes/loginflow/base.php @@ -731,6 +731,10 @@ protected function get_oidc_username_from_token_claim(jwt $idtoken, string $bind if (empty($bindingusernameclaim)) { $bindingusernameclaim = get_config('auth_oidc', 'bindingusernameclaim'); + if (empty($bindingusernameclaim)) { + $bindingusernameclaim = 'auto'; + set_config('bindingusernameclaim', $bindingusernameclaim, 'auth_oidc'); + } } switch ($bindingusernameclaim) { diff --git a/auth/oidc/db/install.php b/auth/oidc/db/install.php new file mode 100644 index 000000000..768eef90f --- /dev/null +++ b/auth/oidc/db/install.php @@ -0,0 +1,35 @@ +. + +/** + * Plugin installation script. + * + * @package auth_oidc + * @author Lai Wei + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) + */ + +/** + * Installation script. + */ +function xmldb_auth_oidc_install() { + // Set the default value for the bindingusernameclaim setting. + $bindingusernameclaimconfig = get_config('auth_oidc', 'bindingusernameclaim'); + if (empty($bindingusernameclaimconfig)) { + set_config('bindingusernameclaim', 'auto', 'auth_oidc'); + } +} diff --git a/auth/oidc/db/upgrade.php b/auth/oidc/db/upgrade.php index c6650e1ab..1cb45db33 100644 --- a/auth/oidc/db/upgrade.php +++ b/auth/oidc/db/upgrade.php @@ -504,5 +504,16 @@ function xmldb_auth_oidc_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2023100921, 'auth', 'oidc'); } + if ($oldversion < 2023100926) { + // Set the default value for the bindingusernameclaim setting. + $bindingusernameclaimconfig = get_config('auth_oidc', 'bindingusernameclaim'); + if (empty($bindingusernameclaimconfig)) { + set_config('bindingusernameclaim', 'auto', 'auth_oidc'); + } + + // Oidc savepoint reached. + upgrade_plugin_savepoint(true, 2023100926, 'auth', 'oidc'); + } + return true; } diff --git a/auth/oidc/lang/en/auth_oidc.php b/auth/oidc/lang/en/auth_oidc.php index 123bbf84e..b1bec1f3b 100644 --- a/auth/oidc/lang/en/auth_oidc.php +++ b/auth/oidc/lang/en/auth_oidc.php @@ -404,7 +404,7 @@
{$a}
'; $string['binding_username_auto'] = 'Choose automatically'; $string['binding_username_custom'] = 'Custom'; -$string['binding_username_claim'] = 'Binding username claim'; +$string['bindingusernameclaim'] = 'Binding username claim'; $string['customclaimname'] = 'Custom claim name'; $string['customclaimname_description'] = 'This field is used only when the Binding Username Claim setting is set to Custom.'; $string['binding_username_claim_help_ms_no_user_sync'] = 'The options for non Microsoft IdPs include: diff --git a/auth/oidc/version.php b/auth/oidc/version.php index fb41e6e57..0780ef48c 100644 --- a/auth/oidc/version.php +++ b/auth/oidc/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023100925; +$plugin->version = 2023100926; $plugin->requires = 2023100900; $plugin->release = '4.3.6'; $plugin->component = 'auth_oidc';