Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions auth/oidc/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ public function handleredirect() {
* @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user, otherwise revert login methods.
* @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account to a
* "linked" account.
* @param moodle_url|null $redirect Where to redirect if successful.
* @param moodle_url|null $selfurl The page this is accessed from. Used for some redirects.
* @param \core\url|null $redirect Where to redirect if successful.
* @param \core\url|null $selfurl The page this is accessed from. Used for some redirects.
* @param null $userid
* @return mixed
*/
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null,
?\moodle_url $selfurl = null, $userid = null) {
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\core\url $redirect = null,
?\core\url $selfurl = null, $userid = null) {
return $this->loginflow->disconnect($justremovetokens, $donotremovetokens, $redirect, $selfurl, $userid);
}

Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/binding_username_claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

require_login();

$url = new moodle_url('/auth/oidc/binding_username_claim.php');
$url = new \core\url('/auth/oidc/binding_username_claim.php');
$PAGE->set_url($url);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
Expand Down Expand Up @@ -97,7 +97,7 @@
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('binding_username_claim_heading', 'auth_oidc'));
$bindingusernametoolurl = new moodle_url('/auth/oidc/change_binding_username_claim_tool.php');
$bindingusernametoolurl = new \core\url('/auth/oidc/change_binding_username_claim_tool.php');
echo html_writer::tag('p', get_string('binding_username_claim_description', 'auth_oidc', $bindingusernametoolurl->out()));
if ($existingclaims) {
echo html_writer::tag('p', get_string('binding_username_claim_description_existing_claims', 'auth_oidc',
Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/change_binding_username_claim_tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

require_login();

$url = new moodle_url('/auth/oidc/change_binding_username_claim_tool.php');
$url = new \core\url('/auth/oidc/change_binding_username_claim_tool.php');
$PAGE->set_url($url);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
Expand Down Expand Up @@ -70,7 +70,7 @@
echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('change_binding_username_claim_tool', 'auth_oidc'));
$bindingusernameclaimurl = new moodle_url('/auth/oidc/binding_username_claim.php');
$bindingusernameclaimurl = new \core\url('/auth/oidc/binding_username_claim.php');
echo html_writer::tag('p', get_string('change_binding_username_claim_tool_description', 'auth_oidc',
$bindingusernameclaimurl->out()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function write_setting($data) {
public function output_html($data, $query = '') {
global $CFG, $OUTPUT;
$attrs = ['type' => 'text/css', 'rel' => 'stylesheet',
'href' => new \moodle_url('/auth/oidc/classes/adminsetting/iconselect.css')];
'href' => new \core\url('/auth/oidc/classes/adminsetting/iconselect.css')];
$html = \html_writer::empty_tag('link', $attrs);
$html .= \html_writer::start_tag('div', ['style' => 'max-width: 390px']);
$selected = (!empty($data)) ? $data : $this->defaultsetting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use core_text;
use csv_import_reader;
use html_writer;
use moodle_url;
use core\url;
use moodleform;

/**
Expand All @@ -43,7 +43,7 @@ class change_binding_username_claim_tool_form1 extends moodleform {
protected function definition() {
$mform =& $this->_form;

$url = new moodle_url('/auth/oidc/example.csv');
$url = new \core\url('/auth/oidc/example.csv');
$link = html_writer::link($url, 'example.csv');
$mform->addElement('static', 'example.csv', get_string('examplecsv', 'auth_oidc'), $link);

Expand Down
16 changes: 8 additions & 8 deletions auth/oidc/classes/loginflow/authcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use core_text;
use core_user;
use moodle_exception;
use moodle_url;
use core\url;
use pix_icon;
use stdClass;

Expand Down Expand Up @@ -74,7 +74,7 @@ public function loginpage_idp_list($wantsurl) {

return [
[
'url' => new moodle_url('/auth/oidc/', ['source' => 'loginpage']),
'url' => new \core\url('/auth/oidc/', ['source' => 'loginpage']),
'icon' => $icon,
'name' => strip_tags(format_text($this->config->opname)),
],
Expand Down Expand Up @@ -116,14 +116,14 @@ public function handleredirect() {
if ($silentloginmode) {
if ($error == 'login_required') {
// If silent login mode is enabled and the error is 'login_required', redirect to the login page.
$loginpageurl = new moodle_url('/login/index.php', ['noredirect' => 1]);
$loginpageurl = new \core\url('/login/index.php', ['noredirect' => 1]);
redirect($loginpageurl);
die();
} else if ($error == 'interaction_required') {
if (strpos($errordescription, 'multiple user identities') !== false) {
$selectaccount = true;
} else {
$loginpageurl = new moodle_url('/login/index.php', ['noredirect' => 1]);
$loginpageurl = new \core\url('/login/index.php', ['noredirect' => 1]);
redirect($loginpageurl);
die();
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public function handleredirect() {
$urltogo = $SESSION->wantsurl;
unset($SESSION->wantsurl);
} else {
$urltogo = new moodle_url('/');
$urltogo = new \core\url('/');
}
redirect($urltogo);
die();
Expand Down Expand Up @@ -283,7 +283,7 @@ protected function handlecertadminconsentresponse(array $authparams) {
$event->trigger();

$redirect = (!empty($additionaldata['redirect'])) ? $additionaldata['redirect'] : '/auth/oidc/ucp.php';
redirect(new moodle_url($redirect));
redirect(new \core\url($redirect));
}

/**
Expand Down Expand Up @@ -381,7 +381,7 @@ protected function handleauthresponse(array $authparams) {
} else {
throw new moodle_exception('errorinvalidredirect_message', 'auth_oidc');
}
redirect(new moodle_url($redirect));
redirect(new \core\url($redirect));
}

// If the user is already logged in we can treat this as a "migration" - a user switching to OIDC.
Expand All @@ -391,7 +391,7 @@ protected function handleauthresponse(array $authparams) {
}
$this->handlemigration($oidcuniqid, $authparams, $tokenparams, $idtoken, $connectiononly);
$redirect = (!empty($additionaldata['redirect'])) ? $additionaldata['redirect'] : '/auth/oidc/ucp.php';
redirect(new moodle_url($redirect));
redirect(new \core\url($redirect));
} else {
// Otherwise it's a user logging in normally with OIDC.
$this->handlelogin($oidcuniqid, $authparams, $tokenparams, $idtoken);
Expand Down
12 changes: 6 additions & 6 deletions auth/oidc/classes/loginflow/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,18 @@ public function set_httpclient(\auth_oidc\httpclientinterface $httpclient) {
* @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user; otherwise, revert login methods.
* @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account
* to a "linked" account.
* @param \moodle_url|null $redirect URL to redirect to if successful.
* @param \moodle_url|null $selfurl The page this is accessed from, used for some redirects.
* @param \core\url|null $redirect URL to redirect to if successful.
* @param \core\url|null $selfurl The page this is accessed from, used for some redirects.
* @param int|null $userid ID of the user to disconnect; uses the current user if not provided.
*/
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null,
?\moodle_url $selfurl = null, $userid = null) {
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\core\url $redirect = null,
?\core\url $selfurl = null, $userid = null) {
global $USER, $DB, $CFG;
if ($redirect === null) {
$redirect = new \moodle_url('/auth/oidc/ucp.php');
$redirect = new \core\url('/auth/oidc/ucp.php');
}
if ($selfurl === null) {
$selfurl = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']);
$selfurl = new \core\url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']);
}

// Get the record of the user involved. Current user if no ID received.
Expand Down
6 changes: 3 additions & 3 deletions auth/oidc/classes/oidcclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace auth_oidc;

use moodle_exception;
use moodle_url;
use core\url;

defined('MOODLE_INTERNAL') || die();

Expand Down Expand Up @@ -276,7 +276,7 @@ public function authrequest($promptlogin = false, array $stateparams = [], array
}

$params = $this->getauthrequestparams($promptlogin, $stateparams, $extraparams, $selectaccount);
$redirecturl = new moodle_url($this->endpoints['auth'], $params);
$redirecturl = new \core\url($this->endpoints['auth'], $params);
redirect($redirecturl);
}

Expand All @@ -290,7 +290,7 @@ public function authrequest($promptlogin = false, array $stateparams = [], array
public function adminconsentrequest(array $stateparams = [], array $extraparams = []) {
$adminconsentendpoint = 'https://login.microsoftonline.com/organizations/v2.0/adminconsent';
$params = $this->getadminconsentrequestparams($stateparams, $extraparams);
$redirecturl = new moodle_url($adminconsentendpoint, $params);
$redirecturl = new \core\url($adminconsentendpoint, $params);
redirect($redirecturl);
}

Expand Down
8 changes: 4 additions & 4 deletions auth/oidc/classes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Exception;
use moodle_exception;
use auth_oidc\event\action_failed;
use moodle_url;
use core\url;

/**
* General purpose utility class.
Expand Down Expand Up @@ -60,7 +60,7 @@ public static function process_json_response($response, array $expectedstructure
$result['error'] === 'invalid_grant' &&
isset($result['error_codes']) && count($result['error_codes']) == 1 &&
$result['error_codes'][0] == 53003) {
$localo365configurationpageurl = new moodle_url('/admin/settings.php', ['section' => 'local_o365']);
$localo365configurationpageurl = new \core\url('/admin/settings.php', ['section' => 'local_o365']);
throw new moodle_exception('settings_adminconsent_error_53003', 'local_o365',
$localo365configurationpageurl, '', $result['error_description']);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ private static function make_json_safe($data) {
* @return string The redirect URL.
*/
public static function get_redirecturl() {
$redirecturl = new moodle_url('/auth/oidc/');
$redirecturl = new \core\url('/auth/oidc/');
return $redirecturl->out(false);
}

Expand All @@ -196,7 +196,7 @@ public static function get_redirecturl() {
* @return string The redirect URL.
*/
public static function get_frontchannellogouturl() {
$logouturl = new moodle_url('/auth/oidc/logout.php');
$logouturl = new \core\url('/auth/oidc/logout.php');
return $logouturl->out(false);
}

Expand Down
2 changes: 1 addition & 1 deletion auth/oidc/cleanupoidctokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
require_login();

$context = context_system::instance();
$pageurl = new moodle_url('/auth/oidc/cleanupoidctokens.php');
$pageurl = new \core\url('/auth/oidc/cleanupoidctokens.php');

admin_externalpage_setup('auth_oidc_cleanup_oidc_tokens');

Expand Down
6 changes: 3 additions & 3 deletions auth/oidc/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function auth_oidc_get_tokens_with_empty_ids() {
$item->oidcuniqueid = $record->oidcuniqid;
$item->matchingstatus = get_string('unmatched', 'auth_oidc');
$item->details = get_string('na', 'auth_oidc');
$deletetokenurl = new moodle_url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]);
$deletetokenurl = new \core\url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]);
$item->action = html_writer::link($deletetokenurl, get_string('delete_token', 'auth_oidc'));

$emptyuseridtokens[$record->id] = $item;
Expand Down Expand Up @@ -234,7 +234,7 @@ function auth_oidc_get_tokens_with_mismatched_usernames() {
$item->matchingstatus = get_string('mismatched', 'auth_oidc');
$item->details = get_string('mismatched_details', 'auth_oidc',
['tokenusername' => $record->tokenusername, 'moodleusername' => $record->musername]);
$deletetokenurl = new moodle_url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]);
$deletetokenurl = new \core\url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]);
$item->action = html_writer::link($deletetokenurl, get_string('delete_token_and_reference', 'auth_oidc'));

$mismatchedtokens[$record->id] = $item;
Expand Down Expand Up @@ -523,7 +523,7 @@ function auth_oidc_display_auth_lock_options($settings, $auth, $userfields, $hel
// Generate the list of fields / mappings.
if ($fieldnametoolong) {
// Display a message that the field can not be mapped because it's too long.
$url = new moodle_url('/user/profile/index.php');
$url = new \core\url('/user/profile/index.php');
$a = (object)['fieldname' => s($fieldname), 'shortname' => s($field), 'charlimit' => 67, 'link' => $url->out()];
$settings->add(new admin_setting_heading($auth.'/field_not_mapped_'.sha1($field), '',
get_string('cannotmapfield', 'auth', $a)));
Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/manageapplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

require_login();

$url = new moodle_url('/auth/oidc/manageapplication.php');
$url = new \core\url('/auth/oidc/manageapplication.php');
$PAGE->set_url($url);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('admin');
Expand Down Expand Up @@ -131,7 +131,7 @@
purge_all_caches();

// Then show the message to the user with instructions to update the application token.
$localo365configurl = new moodle_url('/admin/settings.php', ['section' => 'local_o365']);
$localo365configurl = new \core\url('/admin/settings.php', ['section' => 'local_o365']);
redirect($localo365configurl, get_string('application_updated_microsoft', 'auth_oidc'));
} else {
redirect($url, get_string('application_updated', 'auth_oidc'));
Expand Down
12 changes: 6 additions & 6 deletions auth/oidc/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@

// Application configuration page.
$ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_application', get_string('settings_page_application', 'auth_oidc'),
new moodle_url('/auth/oidc/manageapplication.php')));
new \core\url('/auth/oidc/manageapplication.php')));


$idptype = get_config('auth_oidc', 'idptype');
if ($idptype) {
// Binding username claim page.
$ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_binding_username_claim',
get_string('settings_page_binding_username_claim', 'auth_oidc'),
new moodle_url('/auth/oidc/binding_username_claim.php')));
new \core\url('/auth/oidc/binding_username_claim.php')));

// Change binding username claim tool page.
$ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_change_binding_username_claim_tool',
get_string('settings_page_change_binding_username_claim_tool', 'auth_oidc'),
new moodle_url('/auth/oidc/change_binding_username_claim_tool.php')));
new \core\url('/auth/oidc/change_binding_username_claim_tool.php')));
}


Expand All @@ -69,7 +69,7 @@
get_string('cfg_redirecturi_key', 'auth_oidc'), get_string('cfg_redirecturi_desc', 'auth_oidc'), utils::get_redirecturl()));

// Link to authentication options.
$authenticationconfigurationurl = new moodle_url('/auth/oidc/manageapplication.php');
$authenticationconfigurationurl = new \core\url('/auth/oidc/manageapplication.php');
$settings->add(new admin_setting_description('auth_oidc/authenticationlink',
get_string('settings_page_application', 'auth_oidc'),
get_string('cfg_authenticationlink_desc', 'auth_oidc', $authenticationconfigurationurl->out())));
Expand All @@ -83,7 +83,7 @@
get_string('cfg_forceredirect_key', 'auth_oidc'), get_string('cfg_forceredirect_desc', 'auth_oidc'), 0));

// Silent login mode.
$forceloginconfigurl = new moodle_url('/admin/settings.php', ['section' => 'sitepolicies']);
$forceloginconfigurl = new \core\url('/admin/settings.php', ['section' => 'sitepolicies']);
$settings->add(new admin_setting_configcheckbox('auth_oidc/silentloginmode',
get_string('cfg_silentloginmode_key', 'auth_oidc'),
get_string('cfg_silentloginmode_desc', 'auth_oidc', $forceloginconfigurl->out(false)), 0));
Expand Down Expand Up @@ -243,7 +243,7 @@

// Cleanup OIDC tokens page.
$ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_cleanup_oidc_tokens',
get_string('settings_page_cleanup_oidc_tokens', 'auth_oidc'), new moodle_url('/auth/oidc/cleanupoidctokens.php')));
get_string('settings_page_cleanup_oidc_tokens', 'auth_oidc'), new \core\url('/auth/oidc/cleanupoidctokens.php')));

// Other settings page and its settings.
$fieldmappingspage = new admin_settingpage('auth_oidc_field_mapping', get_string('settings_page_field_mapping', 'auth_oidc'));
Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
echo \html_writer::tag('h4', get_string('ucp_status_enabled', 'auth_oidc'), ['class' => 'notifysuccess']);
if (is_enabled_auth('manual') === true) {
if (auth_oidc_connectioncapability($USER->id, 'disconnect')) {
$connectlinkuri = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']);
$connectlinkuri = new \core\url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']);
$strdisconnect = get_string('ucp_login_stop', 'auth_oidc', $opname);
$linkhtml = \html_writer::link($connectlinkuri, $strdisconnect);
echo \html_writer::tag('h5', $linkhtml);
Expand All @@ -98,7 +98,7 @@
} else {
echo \html_writer::tag('h4', get_string('ucp_status_disabled', 'auth_oidc'), ['class' => 'notifyproblem']);
if (auth_oidc_connectioncapability($USER->id, 'connect')) {
$connectlinkuri = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'connectlogin']);
$connectlinkuri = new \core\url('/auth/oidc/ucp.php', ['action' => 'connectlogin']);
$linkhtml = \html_writer::link($connectlinkuri, get_string('ucp_login_start', 'auth_oidc', $opname));
echo \html_writer::tag('h5', $linkhtml);
echo \html_writer::span(get_string('ucp_login_start_desc', 'auth_oidc', $opname));
Expand Down