Permalink
Browse files

MDL-39409 auth/cas pass web proxy settings along to phpCAS

  • Loading branch information...
1 parent c6be138 commit a7fce608672c1c9080b598084c2442f4c2d1035e @brki brki committed Apr 29, 2013
Showing with 22 additions and 1 deletion.
  1. +22 −1 auth/cas/auth.php
View
@@ -162,7 +162,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.
@@ -173,6 +173,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{

0 comments on commit a7fce60

Please sign in to comment.