From dddcb38ff6bf9b07cfa68d67321b9844be7b3b25 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 17 Nov 2022 21:38:25 +0800 Subject: [PATCH] MDL-78620 auth_cas: Pass base service URL for the CAS client Since phpCAS v1.6.0, a required base service URL parameterneeds to be passed to phpCAS::client(). This is basically the protocol, hostname, and port number (optional) of the site connecting to the CAS server in order for it to perform service URL discovery. --- auth/cas/auth.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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)) {