diff --git a/auth/cas/CAS/CAS.php b/auth/cas/CAS/CAS.php
index 63b6ce4ce42..3d84809c773 100644
--- a/auth/cas/CAS/CAS.php
+++ b/auth/cas/CAS/CAS.php
@@ -63,7 +63,7 @@ if (!defined('E_USER_DEPRECATED')) {
/**
* phpCAS version. accessible for the user by phpCAS::getVersion().
*/
-define('PHPCAS_VERSION', '1.3.3');
+define('PHPCAS_VERSION', '1.3.4');
/**
* @addtogroup public
@@ -138,6 +138,11 @@ define("SAML_SOAP_ENV_CLOSE", '');
*/
define("SAML_ATTRIBUTES", 'SAMLATTRIBS');
+/**
+ * SAML Attributes
+ */
+define("DEFAULT_ERROR", 'Internal script failure');
+
/** @} */
/**
* @addtogroup publicPGTStorage
@@ -241,7 +246,13 @@ define("PHPCAS_LANG_DEFAULT", PHPCAS_LANG_ENGLISH);
/**
* The default directory for the debug file under Unix.
*/
-define('DEFAULT_DEBUG_DIR', '/tmp/');
+function gettmpdir() {
+if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
+if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
+if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
+return "/tmp";
+}
+define('DEFAULT_DEBUG_DIR', gettmpdir()."/");
/** @} */
@@ -271,6 +282,7 @@ class phpCAS
/**
* This variable is used by the interface class phpCAS.
*
+ * @var CAS_Client
* @hideinitializer
*/
private static $_PHPCAS_CLIENT;
@@ -290,6 +302,15 @@ class phpCAS
*/
private static $_PHPCAS_DEBUG;
+ /**
+ * This variable is used to enable verbose mode
+ * This pevents debug info to be show to the user. Since it's a security
+ * feature the default is false
+ *
+ * @hideinitializer
+ */
+ private static $_PHPCAS_VERBOSE = false;
+
// ########################################################################
// INITIALIZATION
@@ -388,6 +409,16 @@ class phpCAS
phpCAS :: traceEnd();
}
+ /**
+ * Answer whether or not the client or proxy has been initialized
+ *
+ * @return bool
+ */
+ public static function isInitialized ()
+ {
+ return (is_object(self::$_PHPCAS_CLIENT));
+ }
+
/** @} */
// ########################################################################
// DEBUGGING
@@ -435,10 +466,38 @@ class phpCAS
self::$_PHPCAS_DEBUG['filename'] = $filename;
self::$_PHPCAS_DEBUG['indent'] = 0;
- phpCAS :: trace('START phpCAS-' . PHPCAS_VERSION . ' ******************');
+ phpCAS :: trace('START ('.date("Y-m-d H:i:s").') phpCAS-' . PHPCAS_VERSION . ' ******************');
}
}
+ /**
+ * Enable verbose errors messages in the website output
+ * This is a security relevant since internal status info may leak an may
+ * help an attacker. Default is therefore false
+ *
+ * @param bool $verbose enable verbose output
+ *
+ * @return void
+ */
+ public static function setVerbose($verbose)
+ {
+ if ($verbose === true) {
+ self::$_PHPCAS_VERBOSE = true;
+ } else {
+ self::$_PHPCAS_VERBOSE = false;
+ }
+ }
+
+
+ /**
+ * Show is verbose mode is on
+ *
+ * @return boot verbose
+ */
+ public static function getVerbose()
+ {
+ return self::$_PHPCAS_VERBOSE;
+ }
/**
* Logs a string in debug mode.
@@ -484,6 +543,7 @@ class phpCAS
*/
public static function error($msg)
{
+ phpCAS :: traceBegin();
$dbg = debug_backtrace();
$function = '?';
$file = '?';
@@ -499,8 +559,12 @@ class phpCAS
}
}
}
- echo "
\nphpCAS error: " . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . " in " . $file . " on line " . $line . "
\n";
- phpCAS :: trace($msg);
+ if (self::$_PHPCAS_VERBOSE) {
+ echo "
\nphpCAS error: " . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . " in " . $file . " on line " . $line . "
\n";
+ } else {
+ echo "
\nError: ". DEFAULT_ERROR ."
\n";
+ }
+ phpCAS :: trace($msg . ' in ' . $file . 'on line ' . $line );
phpCAS :: traceEnd();
throw new CAS_GracefullTerminationException(__CLASS__ . "::" . $function . '(): ' . $msg);
@@ -520,7 +584,8 @@ class phpCAS
}
/**
- * This method is used to indicate the start of the execution of a function in debug mode.
+ * This method is used to indicate the start of the execution of a function
+ * in debug mode.
*
* @return void
*/
@@ -1365,7 +1430,7 @@ class phpCAS
* This method is used to logout from CAS. Halts by redirecting to the CAS
* server.
*
- * @param service $service a URL that will be transmitted to the CAS server
+ * @param string $service a URL that will be transmitted to the CAS server
*
* @return void
*/
@@ -1636,7 +1701,8 @@ class phpCAS
phpCAS::_validateClientExists();
if (self::$_PHPCAS_CLIENT->getServerVersion() !== CAS_VERSION_2_0
- && self::$_PHPCAS_CLIENT->getServerVersion() !== CAS_VERSION_3_0) {
+ && self::$_PHPCAS_CLIENT->getServerVersion() !== CAS_VERSION_3_0
+ ) {
phpCAS :: error('this method can only be used with the cas 2.0/3.0 protocols');
}
self::$_PHPCAS_CLIENT->getAllowedProxyChains()->allowProxyChain($proxy_chain);
diff --git a/auth/cas/CAS/CAS/Client.php b/auth/cas/CAS/CAS/Client.php
index 40e77cdcc23..7282e2883d0 100644
--- a/auth/cas/CAS/CAS/Client.php
+++ b/auth/cas/CAS/CAS/Client.php
@@ -131,9 +131,11 @@ class CAS_Client
$lang = $this->getLangObj();
$this->_htmlFilterOutput(
empty($this->_output_footer)?
- ('
phpCAS __PHPCAS_VERSION__ '
- .$lang->getUsingServer()
- .' __SERVER_BASE_URL__ (CAS __CAS_VERSION__)