diff --git a/admin/index.php b/admin/index.php index 48c714431b2..8d0199ee1dd 100644 --- a/admin/index.php +++ b/admin/index.php @@ -875,6 +875,8 @@ if (empty($CFG->disabledevlibdirscheck) && (is_dir($CFG->dirroot.'/vendor') || i } else { $devlibdir = false; } +// Check if the site is being foced onto ssl. +$overridetossl = !empty($CFG->overridetossl); admin_externalpage_setup('adminnotifications'); @@ -883,4 +885,4 @@ $output = $PAGE->get_renderer('core', 'admin'); echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb, $registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir, - $mobileconfigured); + $mobileconfigured, $overridetossl); diff --git a/admin/renderer.php b/admin/renderer.php index 1fd8cb5ff95..9ea4ea1d280 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -279,13 +279,15 @@ class core_admin_renderer extends plugin_renderer_base { * @param bool $themedesignermode Warn about the theme designer mode. * @param bool $devlibdir Warn about development libs directory presence. * @param bool $mobileconfigured Whether the mobile web services have been enabled + * @param bool $overridetossl Whether or not ssl is being forced. * * @return string HTML to output. */ public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0, - $themedesignermode = false, $devlibdir = false, $mobileconfigured = false) { + $themedesignermode = false, $devlibdir = false, $mobileconfigured = false, + $overridetossl = false) { global $CFG; $output = ''; @@ -301,6 +303,7 @@ class core_admin_renderer extends plugin_renderer_base { $output .= $this->cron_overdue_warning($cronoverdue); $output .= $this->db_problems($dbproblems); $output .= $this->maintenance_mode_warning($maintenancemode); + $output .= $this->overridetossl_warning($overridetossl); $output .= $this->cache_warnings($cachewarnings); $output .= $this->events_handlers($eventshandlers); $output .= $this->registration_warning($registered); @@ -668,6 +671,20 @@ class core_admin_renderer extends plugin_renderer_base { return $this->warning(get_string('sitemaintenancewarning2', 'admin', $url)); } + /** + * Render a warning that ssl is forced because the site was on loginhttps. + * + * @param bool $overridetossl Whether or not ssl is being forced. + * @return string + */ + protected function overridetossl_warning($overridetossl) { + if (!$overridetossl) { + return ''; + } + $warning = get_string('overridetossl', 'core_admin'); + return $this->warning($warning, 'warning'); + } + /** * Display a warning about installing development code if necesary. * @param int $maturity diff --git a/admin/settings/security.php b/admin/settings/security.php index 061d4b1a83e..56b727acfe7 100644 --- a/admin/settings/security.php +++ b/admin/settings/security.php @@ -124,7 +124,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page // "httpsecurity" settingpage $temp = new admin_settingpage('httpsecurity', new lang_string('httpsecurity', 'admin')); - $temp->add(new admin_setting_configcheckbox('loginhttps', new lang_string('loginhttps', 'admin'), new lang_string('configloginhttps', 'admin'), 0)); + $temp->add(new admin_setting_configcheckbox('cookiesecure', new lang_string('cookiesecure', 'admin'), new lang_string('configcookiesecure', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('cookiehttponly', new lang_string('cookiehttponly', 'admin'), new lang_string('configcookiehttponly', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('allowframembedding', new lang_string('allowframembedding', 'admin'), new lang_string('allowframembedding_help', 'admin'), 0)); diff --git a/admin/settings/users.php b/admin/settings/users.php index a82d5d6bf93..7fc752f38e3 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -15,15 +15,10 @@ if ($hassiteconfig or has_capability('moodle/cohort:view', $systemcontext)) { // speedup for non-admins, add all caps used on this page - if (empty($CFG->loginhttps)) { - $securewwwroot = $CFG->wwwroot; - } else { - $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); - } // stuff under the "accounts" subcategory $ADMIN->add('accounts', new admin_externalpage('editusers', new lang_string('userlist','admin'), "$CFG->wwwroot/$CFG->admin/user.php", array('moodle/user:update', 'moodle/user:delete'))); $ADMIN->add('accounts', new admin_externalpage('userbulk', new lang_string('userbulk','admin'), "$CFG->wwwroot/$CFG->admin/user/user_bulk.php", array('moodle/user:update', 'moodle/user:delete'))); - $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$securewwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); + $ADMIN->add('accounts', new admin_externalpage('addnewuser', new lang_string('addnewuser'), "$CFG->wwwroot/user/editadvanced.php?id=-1", 'moodle/user:create')); // "User default preferences" settingpage. $temp = new admin_settingpage('userdefaultpreferences', new lang_string('userdefaultpreferences', 'admin')); diff --git a/admin/tool/mobile/autologin.php b/admin/tool/mobile/autologin.php index d5ef969439a..13154b3d3ef 100644 --- a/admin/tool/mobile/autologin.php +++ b/admin/tool/mobile/autologin.php @@ -31,8 +31,6 @@ $urltogo = optional_param('urltogo', $CFG->wwwroot, PARAM_URL); // URL to red $context = context_system::instance(); $PAGE->set_context($context); -// Force https. -$PAGE->https_required(); // Check if the user is already logged-in. if (isloggedin() and !isguestuser()) { diff --git a/admin/tool/mobile/classes/api.php b/admin/tool/mobile/classes/api.php index 8741016dbe0..bfc42ee0226 100644 --- a/admin/tool/mobile/classes/api.php +++ b/admin/tool/mobile/classes/api.php @@ -134,7 +134,7 @@ class api { list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id); $settings = array( 'wwwroot' => $CFG->wwwroot, - 'httpswwwroot' => $CFG->httpswwwroot, + 'httpswwwroot' => $CFG->wwwroot, 'sitename' => external_format_string($SITE->fullname, $context->id, true), 'guestlogin' => $CFG->guestloginbutton, 'rememberusername' => $CFG->rememberusername, diff --git a/admin/tool/mobile/tests/externallib_test.php b/admin/tool/mobile/tests/externallib_test.php index 328011a492e..b5986aa9d9a 100644 --- a/admin/tool/mobile/tests/externallib_test.php +++ b/admin/tool/mobile/tests/externallib_test.php @@ -235,7 +235,6 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase { // Need to simulate a non HTTPS site here. $CFG->wwwroot = str_replace('https:', 'http:', $CFG->wwwroot); - $CFG->httpswwwroot = str_replace('https:', 'http:', $CFG->wwwroot); $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/admin/user.php b/admin/user.php index 65f9f8ce36a..65bf4e63ec9 100644 --- a/admin/user.php +++ b/admin/user.php @@ -38,12 +38,6 @@ $strunlock = get_string('unlockaccount', 'admin'); $strconfirm = get_string('confirm'); - if (empty($CFG->loginhttps)) { - $securewwwroot = $CFG->wwwroot; - } else { - $securewwwroot = str_replace('http:','https:',$CFG->wwwroot); - } - $returnurl = new moodle_url('/admin/user.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage, 'page'=>$page)); // The $user variable is also used outside of these if statements. @@ -339,7 +333,7 @@ if (has_capability('moodle/user:update', $sitecontext)) { // prevent editing of admins by non-admins if (is_siteadmin($USER) or !is_siteadmin($user)) { - $url = new moodle_url($securewwwroot.'/user/editadvanced.php', array('id'=>$user->id, 'course'=>$site->id)); + $url = new moodle_url('/user/editadvanced.php', array('id'=>$user->id, 'course'=>$site->id)); $buttons[] = html_writer::link($url, $OUTPUT->pix_icon('t/edit', $stredit)); } } @@ -398,7 +392,7 @@ echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl); } if (has_capability('moodle/user:create', $sitecontext)) { - $url = new moodle_url($securewwwroot . '/user/editadvanced.php', array('id' => -1)); + $url = new moodle_url('/user/editadvanced.php', array('id' => -1)); echo $OUTPUT->single_button($url, get_string('addnewuser'), 'get'); } diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index 8bdf91de9e2..9ec9c329cbb 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -90,8 +90,8 @@ class login implements renderable, templatable { $this->autofocusform = !empty($CFG->loginpageautofocus); $this->rememberusername = isset($CFG->rememberusername) and $CFG->rememberusername == 2; - $this->forgotpasswordurl = new moodle_url($CFG->httpswwwroot . '/login/forgot_password.php'); - $this->loginurl = new moodle_url($CFG->httpswwwroot . '/login/index.php'); + $this->forgotpasswordurl = new moodle_url('/login/forgot_password.php'); + $this->loginurl = new moodle_url('/login/index.php'); $this->signupurl = new moodle_url('/login/signup.php'); // Authentication instructions. diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 6cf1f2819ec..91218ad193f 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1671,8 +1671,8 @@ class auth_plugin_ldap extends auth_plugin_base { if ($referer && $referer != $CFG->wwwroot && $referer != $CFG->wwwroot . '/' && - $referer != $CFG->httpswwwroot . '/login/' && - $referer != $CFG->httpswwwroot . '/login/index.php') { + $referer != $CFG->wwwroot . '/login/' && + $referer != $CFG->wwwroot . '/login/index.php') { $SESSION->wantsurl = $referer; } } @@ -1684,7 +1684,7 @@ class auth_plugin_ldap extends auth_plugin_base { $sesskey = sesskey(); redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_magic.php?sesskey='.$sesskey); } else if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { - redirect($CFG->httpswwwroot.'/login/index.php?authldap_skipntlmsso=1'); + redirect($CFG-wwwroot.'/login/index.php?authldap_skipntlmsso=1'); } } redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php'); @@ -1699,7 +1699,7 @@ class auth_plugin_ldap extends auth_plugin_base { // we don't want to use at all. As we can't get rid of it, just point // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there). if (empty($SESSION->wantsurl) - && (get_local_referer() == $CFG->httpswwwroot.'/auth/ldap/ntlmsso_finish.php')) { + && (get_local_referer() == $CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php')) { $SESSION->wantsurl = $CFG->wwwroot; } diff --git a/auth/ldap/ntlmsso_attempt.php b/auth/ldap/ntlmsso_attempt.php index 561d7bf9d47..3a7ad512906 100644 --- a/auth/ldap/ntlmsso_attempt.php +++ b/auth/ldap/ntlmsso_attempt.php @@ -2,9 +2,6 @@ require(__DIR__.'/../../config.php'); -//HTTPS is required in this page when $CFG->loginhttps enabled -$PAGE->https_required(); - $PAGE->set_url('/auth/ldap/ntlmsso_attempt.php'); $PAGE->set_context(context_system::instance()); @@ -33,9 +30,8 @@ $PAGE->set_title("$site->fullname: $loginsite"); $PAGE->set_heading($site->fullname); echo $OUTPUT->header(); -// $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be. $msg = '
'.get_string('ntlmsso_attempting', 'auth_ldap').'
' . '