diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 33b303a0349..1a888207d93 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -179,11 +179,20 @@ class auth_plugin_cas extends auth_plugin_ldap { static $connected = false; if (!$connected) { + // Form the base URL of the server with just the protocol and hostname. + $serverurl = new moodle_url("/"); + $servicebaseurl = $serverurl->get_scheme() ? $serverurl->get_scheme() . "://" : ''; + $servicebaseurl .= $serverurl->get_host(); + // Add the port if set. + $servicebaseurl .= $serverurl->get_port() ? ':' . $serverurl->get_port() : ''; + // Make sure phpCAS doesn't try to start a new PHP session when connecting to the CAS server. if ($this->config->proxycas) { - phpCAS::proxy($this->config->casversion, $this->config->hostname, (int) $this->config->port, $this->config->baseuri, false); + phpCAS::proxy($this->config->casversion, $this->config->hostname, (int) $this->config->port, $this->config->baseuri, + $servicebaseurl, false); } else { - phpCAS::client($this->config->casversion, $this->config->hostname, (int) $this->config->port, $this->config->baseuri, false); + phpCAS::client($this->config->casversion, $this->config->hostname, (int) $this->config->port, + $this->config->baseuri, $servicebaseurl, false); } // Some CAS installs require SSLv3 that should be explicitly set. if (!empty($this->config->curl_ssl_version)) {