Skip to content

Commit

Permalink
MDL-39409 auth/cas pass web proxy settings along to phpCAS
Browse files Browse the repository at this point in the history
  • Loading branch information
brki committed Apr 29, 2013
1 parent cf5a329 commit 5c8535d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion auth/cas/auth.php
Expand Up @@ -164,7 +164,7 @@ function prelogout_hook() {
*
*/
function connectCAS() {
global $PHPCAS_CLIENT;
global $CFG, $PHPCAS_CLIENT;

if (!is_object($PHPCAS_CLIENT)) {
// Make sure phpCAS doesn't try to start a new PHP session when connecting to the CAS server.
Expand All @@ -175,6 +175,27 @@ function connectCAS() {
}
}

// If Moodle is configured to use a proxy, phpCAS needs some curl options set.
if (!empty($CFG->proxyhost) && !is_proxybypass($this->config->hostname)) {
phpCAS::setExtraCurlOption(CURLOPT_PROXY, $CFG->proxyhost);
if (!empty($CFG->proxyport)) {
phpCAS::setExtraCurlOption(CURLOPT_PROXYPORT, $CFG->proxyport);
}
if (!empty($CFG->proxytype)) {
// Only set CURLOPT_PROXYTYPE if it's something other than the curl-default http
if ($CFG->proxytype == 'SOCKS5') {
phpCAS::setExtraCurlOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
}
}
if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
phpCAS::setExtraCurlOption(CURLOPT_PROXYUSERPWD, $CFG->proxyuser.':'.$CFG->proxypassword);
if (defined('CURLOPT_PROXYAUTH')) {
// any proxy authentication if PHP 5.1
phpCAS::setExtraCurlOption(CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
}
}
}

if($this->config->certificate_check && $this->config->certificate_path){
phpCAS::setCasServerCACert($this->config->certificate_path);
}else{
Expand Down

0 comments on commit 5c8535d

Please sign in to comment.