diff --git a/local/o365/classes/task/notifysecretexpiry.php b/local/o365/classes/task/notifysecretexpiry.php index e2a2dd9f9..7467a8e91 100644 --- a/local/o365/classes/task/notifysecretexpiry.php +++ b/local/o365/classes/task/notifysecretexpiry.php @@ -60,13 +60,21 @@ public function get_name(): string { */ public function execute(): bool { if (!utils::is_configured()) { - // Microsoft 365 integration has not been set up; nothing to do. - mtrace('Microsoft 365 integration is not configured. Skipping.'); + // The site is not configured with a Microsoft IdP; nothing to do. + mtrace('The site is not configured with a Microsoft identity provider. Skipping.'); + return true; + } + + if (get_config('auth_oidc', 'clientauthmethod') != AUTH_OIDC_AUTH_METHOD_SECRET) { + // Only the client secret authentication method has a secret that can expire. + mtrace('The client authentication method is not client secret. Skipping.'); return true; } if (utils::is_connected() !== true) { - throw new moodle_exception('error_not_connected', 'local_o365'); + // The Microsoft 365 integration is not set up, so the secret cannot be checked. + mtrace('The Microsoft 365 integration is not connected. Skipping.'); + return true; } try { @@ -77,12 +85,6 @@ public function execute(): bool { throw new moodle_exception('errorcannotgetapiclient', 'local_o365'); } - $authenticationmethod = get_config('auth_oidc', 'clientauthmethod'); - if ($authenticationmethod != AUTH_OIDC_AUTH_METHOD_SECRET) { - // Currently only support client secret authentication method. - throw new moodle_exception('errorunsupportedsecretauthenticationmethod', 'local_o365'); - } - // Resolve and DNS-check the configured notification recipients up front, so that a // misconfigured recipient is reported through the task status (see the check before the // final return) even when no notification is due on this run. diff --git a/local/o365/lang/en/local_o365.php b/local/o365/lang/en/local_o365.php index 5ab826f0d..a9019400d 100644 --- a/local/o365/lang/en/local_o365.php +++ b/local/o365/lang/en/local_o365.php @@ -856,7 +856,6 @@ $string['errorfailedtogetsecrets'] = 'Failed to get secrets.'; $string['errorfailedtosendnotification'] = 'Failed to send notification email to one or more recipients.'; $string['errorsecretexpiryrecipientundeliverable'] = 'One or more configured secret expiry notification recipients cannot receive email (invalid address, or a domain with no MX/A record): {$a}. Update the notification recipients in the OpenID Connect settings.'; -$string['errorunsupportedsecretauthenticationmethod'] = 'This task only supports the client secret authentication method.'; // Privacy API. $string['privacy:metadata:local_o365'] = 'Microsoft 365 Local Plugin';