Merge branch 'MDL-65768-master' of git://github.com/lameze/moodle
This commit is contained in:
+67
-27
@@ -61,13 +61,17 @@ if (!defined('E_USER_DEPRECATED')) {
|
||||
/**
|
||||
* phpCAS version. accessible for the user by phpCAS::getVersion().
|
||||
*/
|
||||
define('PHPCAS_VERSION', '1.3.5+');
|
||||
define('PHPCAS_VERSION', '1.3.7+');
|
||||
|
||||
/**
|
||||
* @addtogroup public
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* phpCAS supported protocols. accessible for the user by phpCAS::getSupportedProtocols().
|
||||
*/
|
||||
|
||||
/**
|
||||
* CAS version 1.0
|
||||
*/
|
||||
@@ -244,6 +248,7 @@ define("PHPCAS_LANG_DEFAULT", PHPCAS_LANG_ENGLISH);
|
||||
|
||||
/**
|
||||
* The default directory for the debug file under Unix.
|
||||
* @return string directory for the debug file
|
||||
*/
|
||||
function gettmpdir() {
|
||||
if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
|
||||
@@ -287,6 +292,7 @@ class phpCAS
|
||||
private static $_PHPCAS_CLIENT;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* This variable is used to store where the initializer is called from
|
||||
* (to print a comprehensive error in case of multiple calls).
|
||||
*
|
||||
@@ -295,6 +301,7 @@ class phpCAS
|
||||
private static $_PHPCAS_INIT_CALL;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* This variable is used to store phpCAS debug mode.
|
||||
*
|
||||
* @hideinitializer
|
||||
@@ -325,12 +332,12 @@ class phpCAS
|
||||
*
|
||||
* @param string $server_version the version of the CAS server
|
||||
* @param string $server_hostname the hostname of the CAS server
|
||||
* @param string $server_port the port the CAS server is running on
|
||||
* @param int $server_port the port the CAS server is running on
|
||||
* @param string $server_uri the URI the CAS server is responding on
|
||||
* @param bool $changeSessionID Allow phpCAS to change the session_id (Single
|
||||
* Sign Out/handleLogoutRequests is based on that change)
|
||||
*
|
||||
* @return a newly created CAS_Client object
|
||||
* @return void a newly created CAS_Client object
|
||||
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
|
||||
* called, only once, and before all other methods (except phpCAS::getVersion()
|
||||
* and phpCAS::setDebug()).
|
||||
@@ -369,12 +376,12 @@ class phpCAS
|
||||
*
|
||||
* @param string $server_version the version of the CAS server
|
||||
* @param string $server_hostname the hostname of the CAS server
|
||||
* @param string $server_port the port the CAS server is running on
|
||||
* @param int $server_port the port the CAS server is running on
|
||||
* @param string $server_uri the URI the CAS server is responding on
|
||||
* @param bool $changeSessionID Allow phpCAS to change the session_id (Single
|
||||
* Sign Out/handleLogoutRequests is based on that change)
|
||||
*
|
||||
* @return a newly created CAS_Client object
|
||||
* @return void a newly created CAS_Client object
|
||||
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
|
||||
* called, only once, and before all other methods (except phpCAS::getVersion()
|
||||
* and phpCAS::setDebug()).
|
||||
@@ -491,7 +498,7 @@ class phpCAS
|
||||
/**
|
||||
* Show is verbose mode is on
|
||||
*
|
||||
* @return boot verbose
|
||||
* @return bool verbose
|
||||
*/
|
||||
public static function getVerbose()
|
||||
{
|
||||
@@ -631,7 +638,7 @@ class phpCAS
|
||||
* This method is used to indicate the end of the execution of a function in
|
||||
* debug mode.
|
||||
*
|
||||
* @param string $res the result of the function
|
||||
* @param mixed $res the result of the function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -642,7 +649,6 @@ class phpCAS
|
||||
} else {
|
||||
self::$_PHPCAS_DEBUG['indent']--;
|
||||
}
|
||||
$dbg = debug_backtrace();
|
||||
$str = '';
|
||||
if (is_object($res)) {
|
||||
$str .= '<= ' . get_class($res);
|
||||
@@ -709,13 +715,29 @@ class phpCAS
|
||||
/**
|
||||
* This method returns the phpCAS version.
|
||||
*
|
||||
* @return the phpCAS version.
|
||||
* @return string the phpCAS version.
|
||||
*/
|
||||
public static function getVersion()
|
||||
{
|
||||
return PHPCAS_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns supported protocols.
|
||||
*
|
||||
* @return array an array of all supported protocols. Use internal protocol name as array key.
|
||||
*/
|
||||
public static function getSupportedProtocols()
|
||||
{
|
||||
$supportedProtocols = array();
|
||||
$supportedProtocols[CAS_VERSION_1_0] = 'CAS 1.0';
|
||||
$supportedProtocols[CAS_VERSION_2_0] = 'CAS 2.0';
|
||||
$supportedProtocols[CAS_VERSION_3_0] = 'CAS 3.0';
|
||||
$supportedProtocols[SAML_VERSION_1_1] = 'SAML 1.1';
|
||||
|
||||
return $supportedProtocols;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
// ########################################################################
|
||||
// HTML OUTPUT
|
||||
@@ -773,8 +795,8 @@ class phpCAS
|
||||
/**
|
||||
* This method can be used to set a custom PGT storage object.
|
||||
*
|
||||
* @param CAS_PGTStorage $storage a PGT storage object that inherits from the
|
||||
* CAS_PGTStorage class
|
||||
* @param CAS_PGTStorage_AbstractStorage $storage a PGT storage object that inherits from the
|
||||
* CAS_PGTStorage_AbstractStorage class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -903,7 +925,7 @@ class phpCAS
|
||||
* This method is used to access an HTTP[S] service.
|
||||
*
|
||||
* @param string $url the service to access.
|
||||
* @param string &$err_code an error code Possible values are
|
||||
* @param int &$err_code an error code Possible values are
|
||||
* PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE,
|
||||
* PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE,
|
||||
* PHPCAS_SERVICE_NOT_AVAILABLE.
|
||||
@@ -936,7 +958,7 @@ class phpCAS
|
||||
* including the mailing box for IMAP URLs, as accepted by imap_open().
|
||||
* @param string $service a string giving for CAS retrieve Proxy ticket
|
||||
* @param string $flags options given to imap_open().
|
||||
* @param string &$err_code an error code Possible values are
|
||||
* @param int &$err_code an error code Possible values are
|
||||
* PHPCAS_SERVICE_OK (on success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE,
|
||||
* PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, PHPCAS_SERVICE_PT_FAILURE,
|
||||
* PHPCAS_SERVICE_NOT_AVAILABLE.
|
||||
@@ -944,7 +966,7 @@ class phpCAS
|
||||
* @param string &$pt the Proxy Ticket (PT) retrieved from the CAS
|
||||
* server to access the URL on success, false on error).
|
||||
*
|
||||
* @return object IMAP stream on success, false otherwise (in this later
|
||||
* @return object|false IMAP stream on success, false otherwise (in this later
|
||||
* case, $err_code gives the reason why it failed and $err_msg contains an
|
||||
* error message).
|
||||
*/
|
||||
@@ -1027,7 +1049,7 @@ class phpCAS
|
||||
* logs in (such as registering an account, performing logging, etc), register
|
||||
* a callback function here.
|
||||
*
|
||||
* @param string $function Callback function
|
||||
* @param callable $function Callback function
|
||||
* @param array $additionalArgs optional array of arguments
|
||||
*
|
||||
* @return void
|
||||
@@ -1048,7 +1070,7 @@ class phpCAS
|
||||
* applications that manage their own sessions (rather than letting phpCAS
|
||||
* start and destroy the session).
|
||||
*
|
||||
* @param string $function Callback function
|
||||
* @param callable $function Callback function
|
||||
* @param array $additionalArgs optional array of arguments
|
||||
*
|
||||
* @return void
|
||||
@@ -1066,7 +1088,7 @@ class phpCAS
|
||||
* determined by a cas gateway call.(cas login call without any interactive
|
||||
* prompt)
|
||||
*
|
||||
* @return true when the user is authenticated, false when a previous
|
||||
* @return bool true when the user is authenticated, false when a previous
|
||||
* gateway login failed or the function will not return if the user is
|
||||
* redirected to the cas server for a gateway login attempt
|
||||
*/
|
||||
@@ -1134,7 +1156,7 @@ class phpCAS
|
||||
* This method is called to check if the user is authenticated (previously or by
|
||||
* tickets given in the URL).
|
||||
*
|
||||
* @return true when the user is authenticated.
|
||||
* @return bool true when the user is authenticated.
|
||||
*/
|
||||
public static function isAuthenticated()
|
||||
{
|
||||
@@ -1269,7 +1291,7 @@ class phpCAS
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function handleLogoutRequests($check_client = true, $allowed_clients = false)
|
||||
public static function handleLogoutRequests($check_client = true, $allowed_clients = array())
|
||||
{
|
||||
phpCAS::_validateClientExists();
|
||||
|
||||
@@ -1278,9 +1300,8 @@ class phpCAS
|
||||
|
||||
/**
|
||||
* This method returns the URL to be used to login.
|
||||
* or phpCAS::isAuthenticated().
|
||||
*
|
||||
* @return the login name of the authenticated user
|
||||
* @return string the login URL
|
||||
*/
|
||||
public static function getServerLoginURL()
|
||||
{
|
||||
@@ -1385,10 +1406,9 @@ class phpCAS
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the URL to be used to login.
|
||||
* or phpCAS::isAuthenticated().
|
||||
* This method returns the URL to be used to logout.
|
||||
*
|
||||
* @return the login name of the authenticated user
|
||||
* @return string the URL to use to log out
|
||||
*/
|
||||
public static function getServerLogoutURL()
|
||||
{
|
||||
@@ -1592,7 +1612,7 @@ class phpCAS
|
||||
* Retrieve a Proxy Ticket from the CAS server.
|
||||
*
|
||||
* @param string $target_service Url string of service to proxy
|
||||
* @param string &$err_code error code
|
||||
* @param int &$err_code error code
|
||||
* @param string &$err_msg error message
|
||||
*
|
||||
* @return string Proxy Ticket
|
||||
@@ -1685,6 +1705,27 @@ class phpCAS
|
||||
phpCAS :: traceEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a salt/seed for the session-id hash to make it harder to guess.
|
||||
*
|
||||
* When $changeSessionID = true phpCAS will create a session-id that is derived
|
||||
* from the service ticket. Doing so allows phpCAS to look-up and destroy the
|
||||
* proper session on single-log-out requests. While the service tickets
|
||||
* provided by the CAS server may include enough data to generate a strong
|
||||
* hash, clients may provide an additional salt to ensure that session ids
|
||||
* are not guessable if the session tickets do not have enough entropy.
|
||||
*
|
||||
* @param string $salt The salt to combine with the session ticket.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setSessionIdSalt($salt) {
|
||||
phpCAS :: traceBegin();
|
||||
phpCAS::_validateClientExists();
|
||||
self::$_PHPCAS_CLIENT->setSessionIdSalt($salt);
|
||||
phpCAS :: traceEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want your service to be proxied you have to enable it (default
|
||||
* disabled) and define an accepable list of proxies that are allowed to
|
||||
@@ -1711,7 +1752,7 @@ class phpCAS
|
||||
* For quick testing or in certain production screnarios you might want to
|
||||
* allow allow any other valid service to proxy your service. To do so, add
|
||||
* the "Any" chain:
|
||||
* phpcas::allowProxyChain(new CAS_ProxyChain_Any);
|
||||
* phpCAS::allowProxyChain(new CAS_ProxyChain_Any);
|
||||
* THIS SETTING IS HOWEVER NOT RECOMMENDED FOR PRODUCTION AND HAS SECURITY
|
||||
* IMPLICATIONS: YOU ARE ALLOWING ANY SERVICE TO ACT ON BEHALF OF A USER
|
||||
* ON THIS SERVICE.
|
||||
@@ -1991,4 +2032,3 @@ class phpCAS
|
||||
/**
|
||||
* @example example_advanced_saml11.php
|
||||
*/
|
||||
?>
|
||||
|
||||
@@ -66,7 +66,7 @@ implements CAS_Exception
|
||||
* @param string $err_msg the error message given by the CAS server
|
||||
*/
|
||||
public function __construct($client,$failure,$cas_url,$no_response,
|
||||
$bad_response='',$cas_response='',$err_code='',$err_msg=''
|
||||
$bad_response=false,$cas_response='',$err_code=-1,$err_msg=''
|
||||
) {
|
||||
$messages = array();
|
||||
phpCAS::traceBegin();
|
||||
@@ -91,7 +91,7 @@ implements CAS_Exception
|
||||
break;
|
||||
case CAS_VERSION_2_0:
|
||||
case CAS_VERSION_3_0:
|
||||
if ( empty($err_code) ) {
|
||||
if ( $err_code === -1 ) {
|
||||
phpCAS::trace($messages[] = 'Reason: no CAS error');
|
||||
} else {
|
||||
phpCAS::trace($messages[] = 'Reason: ['.$err_code.'] CAS error: '.$err_msg);
|
||||
|
||||
+139
-127
@@ -131,7 +131,7 @@ class CAS_Client
|
||||
$lang = $this->getLangObj();
|
||||
$this->_htmlFilterOutput(
|
||||
empty($this->_output_footer)?
|
||||
(phpcas::getVerbose())?
|
||||
(phpCAS::getVerbose())?
|
||||
'<hr><address>phpCAS __PHPCAS_VERSION__ '
|
||||
.$lang->getUsingServer()
|
||||
.' <a href="__SERVER_BASE_URL__">__SERVER_BASE_URL__</a> (CAS __CAS_VERSION__)</a></address></body></html>'
|
||||
@@ -260,7 +260,7 @@ class CAS_Client
|
||||
* @hideinitializer
|
||||
*/
|
||||
private $_server = array(
|
||||
'version' => -1,
|
||||
'version' => '',
|
||||
'hostname' => 'none',
|
||||
'port' => -1,
|
||||
'uri' => 'none');
|
||||
@@ -288,7 +288,7 @@ class CAS_Client
|
||||
/**
|
||||
* This method is used to retrieve the port of the CAS server.
|
||||
*
|
||||
* @return string the port of the CAS server.
|
||||
* @return int the port of the CAS server.
|
||||
*/
|
||||
private function _getServerPort()
|
||||
{
|
||||
@@ -330,7 +330,7 @@ class CAS_Client
|
||||
* @param bool $gateway true to check authentication, false to force it
|
||||
* @param bool $renew true to force the authentication with the CAS server
|
||||
*
|
||||
* @return a URL.
|
||||
* @return string a URL.
|
||||
* @note It is recommended that CAS implementations ignore the "gateway"
|
||||
* parameter if "renew" is set
|
||||
*/
|
||||
@@ -667,7 +667,7 @@ class CAS_Client
|
||||
$this->_casAttributeParserCallbackArgs = $additionalArgs;
|
||||
}
|
||||
|
||||
/** @var callback $_postAuthenticateCallbackFunction;
|
||||
/** @var callable $_postAuthenticateCallbackFunction;
|
||||
*/
|
||||
private $_postAuthenticateCallbackFunction = null;
|
||||
|
||||
@@ -690,7 +690,7 @@ class CAS_Client
|
||||
* logs in (such as registering an account, performing logging, etc), register
|
||||
* a callback function here.
|
||||
*
|
||||
* @param string $function callback function to call
|
||||
* @param callable $function callback function to call
|
||||
* @param array $additionalArgs optional array of arguments
|
||||
*
|
||||
* @return void
|
||||
@@ -702,7 +702,7 @@ class CAS_Client
|
||||
}
|
||||
|
||||
/**
|
||||
* @var callback $_signoutCallbackFunction;
|
||||
* @var callable $_signoutCallbackFunction;
|
||||
*/
|
||||
private $_signoutCallbackFunction = null;
|
||||
|
||||
@@ -720,7 +720,7 @@ class CAS_Client
|
||||
* order to support single-signout in applications that manage their own sessions
|
||||
* (rather than letting phpCAS start and destroy the session).
|
||||
*
|
||||
* @param string $function callback function to call
|
||||
* @param callable $function callback function to call
|
||||
* @param array $additionalArgs optional array of arguments
|
||||
*
|
||||
* @return void
|
||||
@@ -815,7 +815,7 @@ class CAS_Client
|
||||
* Ensure that authentication was checked. Terminate with exception if no
|
||||
* authentication was performed
|
||||
*
|
||||
* @throws CAS_OutOfSequenceBeforeAuthenticationCallException
|
||||
* @throws CAS_OutOfSequenceException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -839,7 +839,7 @@ class CAS_Client
|
||||
* Throws a CAS_OutOfSequenceException if wasAuthenticationCalled() is false
|
||||
* and markAuthenticationCall() didn't happen.
|
||||
*
|
||||
* @return array Keys are 'file', 'line', and 'method'
|
||||
* @return string the file that called authentication
|
||||
*/
|
||||
public function getAuthenticationCallerFile ()
|
||||
{
|
||||
@@ -853,7 +853,7 @@ class CAS_Client
|
||||
* Throws a CAS_OutOfSequenceException if wasAuthenticationCalled() is false
|
||||
* and markAuthenticationCall() didn't happen.
|
||||
*
|
||||
* @return array Keys are 'file', 'line', and 'method'
|
||||
* @return int the line that called authentication
|
||||
*/
|
||||
public function getAuthenticationCallerLine ()
|
||||
{
|
||||
@@ -867,7 +867,7 @@ class CAS_Client
|
||||
* Throws a CAS_OutOfSequenceException if wasAuthenticationCalled() is false
|
||||
* and markAuthenticationCall() didn't happen.
|
||||
*
|
||||
* @return array Keys are 'file', 'line', and 'method'
|
||||
* @return string the method that called authentication
|
||||
*/
|
||||
public function getAuthenticationCallerMethod ()
|
||||
{
|
||||
@@ -897,7 +897,7 @@ class CAS_Client
|
||||
* (Single Sign Out/handleLogoutRequests
|
||||
* is based on that change)
|
||||
*
|
||||
* @return a newly created CAS_Client object
|
||||
* @return self a newly created CAS_Client object
|
||||
*/
|
||||
public function __construct(
|
||||
$server_version,
|
||||
@@ -953,31 +953,26 @@ class CAS_Client
|
||||
);
|
||||
}
|
||||
|
||||
//check version
|
||||
switch ($server_version) {
|
||||
case CAS_VERSION_1_0:
|
||||
if ( $this->isProxy() ) {
|
||||
phpCAS::error(
|
||||
'CAS proxies are not supported in CAS '.$server_version
|
||||
);
|
||||
}
|
||||
break;
|
||||
case CAS_VERSION_2_0:
|
||||
case CAS_VERSION_3_0:
|
||||
break;
|
||||
case SAML_VERSION_1_1:
|
||||
break;
|
||||
default:
|
||||
// check version
|
||||
$supportedProtocols = phpCAS::getSupportedProtocols();
|
||||
if (isset($supportedProtocols[$server_version]) === false) {
|
||||
phpCAS::error(
|
||||
'this version of CAS (`'.$server_version
|
||||
.'\') is not supported by phpCAS '.phpCAS::getVersion()
|
||||
);
|
||||
}
|
||||
|
||||
if ($server_version === CAS_VERSION_1_0 && $this->isProxy()) {
|
||||
phpCAS::error(
|
||||
'CAS proxies are not supported in CAS '.$server_version
|
||||
);
|
||||
}
|
||||
|
||||
$this->_server['version'] = $server_version;
|
||||
|
||||
// check hostname
|
||||
if ( empty($server_hostname)
|
||||
|| !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)
|
||||
|| !preg_match('/[\.\d\-a-z]*/', $server_hostname)
|
||||
) {
|
||||
phpCAS::error('bad CAS server hostname (`'.$server_hostname.'\')');
|
||||
}
|
||||
@@ -992,7 +987,7 @@ class CAS_Client
|
||||
$this->_server['port'] = $server_port;
|
||||
|
||||
// check URI
|
||||
if ( !preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/', $server_uri) ) {
|
||||
if ( !preg_match('/[\.\d\-_a-z\/]*/', $server_uri) ) {
|
||||
phpCAS::error('bad CAS server URI (`'.$server_uri.'\')');
|
||||
}
|
||||
// add leading and trailing `/' and remove doubles
|
||||
@@ -1047,15 +1042,15 @@ class CAS_Client
|
||||
|
||||
|
||||
/**
|
||||
* A variable to whether phpcas will use its own session handling. Default = true
|
||||
* @var bool A variable to whether phpcas will use its own session handling. Default = true
|
||||
* @hideinitializer
|
||||
*/
|
||||
private $_change_session_id = true;
|
||||
|
||||
/**
|
||||
* Set a parameter whether to allow phpCas to change session_id
|
||||
* Set a parameter whether to allow phpCAS to change session_id
|
||||
*
|
||||
* @param bool $allowed allow phpCas to change session_id
|
||||
* @param bool $allowed allow phpCAS to change session_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1065,7 +1060,7 @@ class CAS_Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether phpCas is allowed to change session_id
|
||||
* Get whether phpCAS is allowed to change session_id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -1167,7 +1162,7 @@ class CAS_Client
|
||||
/**
|
||||
* Get an key values arry of attributes
|
||||
*
|
||||
* @return arry of attributes
|
||||
* @return array of attributes
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
@@ -1246,7 +1241,7 @@ class CAS_Client
|
||||
* If the user is authenticated, renew the connection
|
||||
* If not, redirect to CAS
|
||||
*
|
||||
* @return true when the user is authenticated; otherwise halt.
|
||||
* @return bool true when the user is authenticated; otherwise halt.
|
||||
*/
|
||||
public function renewAuthentication()
|
||||
{
|
||||
@@ -1271,7 +1266,7 @@ class CAS_Client
|
||||
* This method is called to be sure that the user is authenticated. When not
|
||||
* authenticated, halt by redirecting to the CAS server; otherwise return true.
|
||||
*
|
||||
* @return true when the user is authenticated; otherwise halt.
|
||||
* @return bool true when the user is authenticated; otherwise halt.
|
||||
*/
|
||||
public function forceAuthentication()
|
||||
{
|
||||
@@ -1320,14 +1315,13 @@ class CAS_Client
|
||||
/**
|
||||
* This method is called to check whether the user is authenticated or not.
|
||||
*
|
||||
* @return true when the user is authenticated, false when a previous
|
||||
* @return bool true when the user is authenticated, false when a previous
|
||||
* gateway login failed or the function will not return if the user is
|
||||
* redirected to the cas server for a gateway login attempt
|
||||
*/
|
||||
public function checkAuthentication()
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
$res = false;
|
||||
if ( $this->isAuthenticated() ) {
|
||||
phpCAS::trace('user is authenticated');
|
||||
/* The 'auth_checked' variable is removed just in case it's set. */
|
||||
@@ -1382,7 +1376,7 @@ class CAS_Client
|
||||
*
|
||||
* @param bool $renew true to force the authentication with the CAS server
|
||||
*
|
||||
* @return true when the user is authenticated. Also may redirect to the
|
||||
* @return bool true when the user is authenticated. Also may redirect to the
|
||||
* same URL without the ticket.
|
||||
*/
|
||||
public function isAuthenticated($renew=false)
|
||||
@@ -1531,7 +1525,7 @@ class CAS_Client
|
||||
/**
|
||||
* This method tells if the current session is authenticated.
|
||||
*
|
||||
* @return true if authenticated based soley on $_SESSION variable
|
||||
* @return bool true if authenticated based soley on $_SESSION variable
|
||||
*/
|
||||
public function isSessionAuthenticated ()
|
||||
{
|
||||
@@ -1544,7 +1538,7 @@ class CAS_Client
|
||||
*
|
||||
* @note This function switches to callback mode when needed.
|
||||
*
|
||||
* @return true when the user has already been authenticated; false otherwise.
|
||||
* @return bool true when the user has already been authenticated; false otherwise.
|
||||
*/
|
||||
private function _wasPreviouslyAuthenticated()
|
||||
{
|
||||
@@ -1727,12 +1721,12 @@ class CAS_Client
|
||||
*
|
||||
* @param bool $check_client true to check the client bofore handling
|
||||
* the request, false not to perform any access control. True by default.
|
||||
* @param bool $allowed_clients an array of host names allowed to send
|
||||
* @param array $allowed_clients an array of host names allowed to send
|
||||
* logout requests.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleLogoutRequests($check_client=true, $allowed_clients=false)
|
||||
public function handleLogoutRequests($check_client=true, $allowed_clients=array())
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
if (!$this->_isLogoutRequest()) {
|
||||
@@ -1752,7 +1746,7 @@ class CAS_Client
|
||||
phpCAS::trace("SAML REQUEST: ".$decoded_logout_rq);
|
||||
$allowed = false;
|
||||
if ($check_client) {
|
||||
if (!$allowed_clients) {
|
||||
if ($allowed_clients === array()) {
|
||||
$allowed_clients = array( $this->_getServerHostname() );
|
||||
}
|
||||
$client_ip = $_SERVER['REMOTE_ADDR'];
|
||||
@@ -1808,7 +1802,7 @@ class CAS_Client
|
||||
// If phpCAS is managing the session_id, destroy session thanks to
|
||||
// session_id.
|
||||
if ($this->getChangeSessionID()) {
|
||||
$session_id = preg_replace('/[^a-zA-Z0-9\-]/', '', $ticket2logout);
|
||||
$session_id = $this->_sessionIdForTicket($ticket2logout);
|
||||
phpCAS::trace("Session id: ".$session_id);
|
||||
|
||||
// destroy a possible application session created before phpcas
|
||||
@@ -1905,7 +1899,7 @@ class CAS_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* the certificate of the CAS server CA.
|
||||
* @var string the certificate of the CAS server CA.
|
||||
*
|
||||
* @hideinitializer
|
||||
*/
|
||||
@@ -1981,11 +1975,11 @@ class CAS_Client
|
||||
*
|
||||
* @return bool true when successfull and issue a CAS_AuthenticationException
|
||||
* and false on an error
|
||||
* @throws CAS_AuthenticationException
|
||||
*/
|
||||
public function validateCAS10(&$validate_url,&$text_response,&$tree_response,$renew=false)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
$result = false;
|
||||
// build the URL to validate the ticket
|
||||
$validate_url = $this->getServerServiceValidateURL()
|
||||
.'&ticket='.urlencode($this->getTicket());
|
||||
@@ -2004,7 +1998,6 @@ class CAS_Client
|
||||
$this, 'CAS 1.0 ticket not validated', $validate_url,
|
||||
true/*$no_response*/
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if (preg_match('/^no\n/', $text_response)) {
|
||||
@@ -2013,23 +2006,19 @@ class CAS_Client
|
||||
$this, 'ST not validated', $validate_url, false/*$no_response*/,
|
||||
false/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if (!preg_match('/^yes\n/', $text_response)) {
|
||||
phpCAS::trace('ill-formed response');
|
||||
throw new CAS_AuthenticationException(
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
false/*$no_response*/, true/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
// ticket has been validated, extract the user name
|
||||
$arr = preg_split('/\n/', $text_response);
|
||||
$this->_setUser(trim($arr[1]));
|
||||
$result = true;
|
||||
|
||||
if ($result) {
|
||||
$this->_renameSession($this->getTicket());
|
||||
}
|
||||
$this->_renameSession($this->getTicket());
|
||||
|
||||
// at this step, ticket has been validated and $this->_user has been set,
|
||||
phpCAS::traceEnd(true);
|
||||
return true;
|
||||
@@ -2061,6 +2050,8 @@ class CAS_Client
|
||||
*
|
||||
* @return bool true when successfull and issue a CAS_AuthenticationException
|
||||
* and false on an error
|
||||
*
|
||||
* @throws CAS_AuthenticationException
|
||||
*/
|
||||
public function validateSA(&$validate_url,&$text_response,&$tree_response,$renew=false)
|
||||
{
|
||||
@@ -2101,7 +2092,6 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
// read the root node of the XML tree
|
||||
if (!($tree_response = $dom->documentElement)) {
|
||||
@@ -2111,7 +2101,6 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if ( $tree_response->localName != 'Envelope' ) {
|
||||
// insure that tag name is 'Envelope'
|
||||
phpCAS::trace(
|
||||
@@ -2123,7 +2112,6 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if ($tree_response->getElementsByTagName("NameIdentifier")->length != 0) {
|
||||
// check for the NameIdentifier tag in the SAML response
|
||||
$success_elements = $tree_response->getElementsByTagName("NameIdentifier");
|
||||
@@ -2140,7 +2128,6 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
@@ -2172,7 +2159,7 @@ class CAS_Client
|
||||
// Fix possible whitspace problems
|
||||
$dom->preserveWhiteSpace = false;
|
||||
if (($dom->loadXML($text_response))) {
|
||||
$xPath = new DOMXpath($dom);
|
||||
$xPath = new DOMXPath($dom);
|
||||
$xPath->registerNamespace('samlp', 'urn:oasis:names:tc:SAML:1.0:protocol');
|
||||
$xPath->registerNamespace('saml', 'urn:oasis:names:tc:SAML:1.0:assertion');
|
||||
$nodelist = $xPath->query("//saml:Attribute");
|
||||
@@ -2224,20 +2211,21 @@ class CAS_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var bool is the client a proxy
|
||||
* A boolean telling if the client is a CAS proxy or not. Written by
|
||||
* CAS_Client::CAS_Client(), read by CAS_Client::isProxy().
|
||||
*/
|
||||
private $_proxy;
|
||||
|
||||
/**
|
||||
* Handler for managing service cookies.
|
||||
* @var CAS_CookieJar Handler for managing service cookies.
|
||||
*/
|
||||
private $_serviceCookieJar;
|
||||
|
||||
/**
|
||||
* Tells if a CAS client is a CAS proxy or not
|
||||
*
|
||||
* @return true when the CAS client is a CAs proxy, false otherwise
|
||||
* @return bool true when the CAS client is a CAS proxy, false otherwise
|
||||
*/
|
||||
public function isProxy()
|
||||
{
|
||||
@@ -2288,7 +2276,7 @@ class CAS_Client
|
||||
/**
|
||||
* This method tells if a Proxy Granting Ticket was stored.
|
||||
*
|
||||
* @return true if a Proxy Granting Ticket has been stored.
|
||||
* @return bool true if a Proxy Granting Ticket has been stored.
|
||||
*/
|
||||
private function _hasPGT()
|
||||
{
|
||||
@@ -2311,7 +2299,7 @@ class CAS_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* a boolean to know if the CAS client is running in callback mode. Written by
|
||||
* @var bool a boolean to know if the CAS client is running in callback mode. Written by
|
||||
* CAS_Client::setCallBackMode(), read by CAS_Client::_isCallbackMode().
|
||||
*
|
||||
* @hideinitializer
|
||||
@@ -2331,10 +2319,10 @@ class CAS_Client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns true when the CAs client is running i callback mode,
|
||||
* This method returns true when the CAS client is running in callback mode,
|
||||
* false otherwise.
|
||||
*
|
||||
* @return A boolean.
|
||||
* @return bool A boolean.
|
||||
*/
|
||||
private function _isCallbackMode()
|
||||
{
|
||||
@@ -2355,13 +2343,12 @@ class CAS_Client
|
||||
* fact the URL of the current request without any CGI parameter, except if
|
||||
* phpCAS::setFixedCallbackURL() was used).
|
||||
*
|
||||
* @return The callback URL
|
||||
* @return string The callback URL
|
||||
*/
|
||||
private function _getCallbackURL()
|
||||
{
|
||||
// the URL is built when needed only
|
||||
if ( empty($this->_callback_url) ) {
|
||||
$final_uri = '';
|
||||
// remove the ticket if present in the URL
|
||||
$final_uri = 'https://';
|
||||
$final_uri .= $this->_getClientUrl();
|
||||
@@ -2378,7 +2365,7 @@ class CAS_Client
|
||||
*
|
||||
* @param string $url url to set callback
|
||||
*
|
||||
* @return void
|
||||
* @return string the callback url
|
||||
*/
|
||||
public function setCallbackURL($url)
|
||||
{
|
||||
@@ -2400,8 +2387,8 @@ class CAS_Client
|
||||
private function _callback()
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
if (preg_match('/PGTIOU-[\.\-\w]/', $_GET['pgtIou'])) {
|
||||
if (preg_match('/[PT]GT-[\.\-\w]/', $_GET['pgtId'])) {
|
||||
if (preg_match('/^PGTIOU-[\.\-\w]+$/', $_GET['pgtIou'])) {
|
||||
if (preg_match('/^[PT]GT-[\.\-\w]+$/', $_GET['pgtId'])) {
|
||||
$this->printHTMLHeader('phpCAS callback');
|
||||
$pgt_iou = $_GET['pgtIou'];
|
||||
$pgt = $_GET['pgtId'];
|
||||
@@ -2438,6 +2425,7 @@ class CAS_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var CAS_PGTStorage_AbstractStorage
|
||||
* an instance of a class inheriting of PGTStorage, used to deal with PGT
|
||||
* storage. Created by CAS_Client::setPGTStorageFile(), used
|
||||
* by CAS_Client::setPGTStorageFile() and CAS_Client::_initPGTStorage().
|
||||
@@ -2485,7 +2473,7 @@ class CAS_Client
|
||||
*
|
||||
* @param string $pgt_iou the PGT Iou
|
||||
*
|
||||
* @return mul The PGT corresponding to the Iou, false when not found.
|
||||
* @return string mul The PGT corresponding to the Iou, false when not found.
|
||||
*/
|
||||
private function _loadPGT($pgt_iou)
|
||||
{
|
||||
@@ -2525,7 +2513,7 @@ class CAS_Client
|
||||
* This method is used to tell phpCAS to store the response of the
|
||||
* CAS server to PGT requests in a database.
|
||||
*
|
||||
* @param string $dsn_or_pdo a dsn string to use for creating a PDO
|
||||
* @param string|PDO $dsn_or_pdo a dsn string to use for creating a PDO
|
||||
* object or a PDO object
|
||||
* @param string $username the username to use when connecting to the
|
||||
* database
|
||||
@@ -2545,7 +2533,7 @@ class CAS_Client
|
||||
$this->ensureIsProxy();
|
||||
|
||||
// Argument validation
|
||||
if ((is_object($dsn_or_pdo) && !($dsn_or_pdo instanceof PDO)) || gettype($dsn_or_pdo) != 'string')
|
||||
if (!(is_object($dsn_or_pdo) && $dsn_or_pdo instanceof PDO) && !is_string($dsn_or_pdo))
|
||||
throw new CAS_TypeMismatchException($dsn_or_pdo, '$dsn_or_pdo', 'string or PDO object');
|
||||
if (gettype($username) != 'string')
|
||||
throw new CAS_TypeMismatchException($username, '$username', 'string');
|
||||
@@ -2595,11 +2583,13 @@ class CAS_Client
|
||||
* (XML text); result of
|
||||
* CAS_Client::validateCAS10() or
|
||||
* CAS_Client::validateCAS20().
|
||||
* @param string $tree_response the response of the CAS server, as a DOM XML
|
||||
* @param DOMElement $tree_response the response of the CAS server, as a DOM XML
|
||||
* tree; result of CAS_Client::validateCAS10() or CAS_Client::validateCAS20().
|
||||
*
|
||||
* @return bool true when successfull and issue a CAS_AuthenticationException
|
||||
* and false on an error
|
||||
*
|
||||
* @throws CAS_AuthenticationException
|
||||
*/
|
||||
private function _validatePGT(&$validate_url,$text_response,$tree_response)
|
||||
{
|
||||
@@ -2617,7 +2607,7 @@ class CAS_Client
|
||||
$pgt_iou = trim(
|
||||
$tree_response->getElementsByTagName("proxyGrantingTicket")->item(0)->nodeValue
|
||||
);
|
||||
if (preg_match('/PGTIOU-[\.\-\w]/', $pgt_iou)) {
|
||||
if (preg_match('/^PGTIOU-[\.\-\w]+$/', $pgt_iou)) {
|
||||
$pgt = $this->_loadPGT($pgt_iou);
|
||||
if ( $pgt == false ) {
|
||||
phpCAS::trace('could not load PGT');
|
||||
@@ -2650,10 +2640,10 @@ class CAS_Client
|
||||
* This method is used to retrieve PT's from the CAS server thanks to a PGT.
|
||||
*
|
||||
* @param string $target_service the service to ask for with the PT.
|
||||
* @param string &$err_code an error code (PHPCAS_SERVICE_OK on success).
|
||||
* @param int &$err_code an error code (PHPCAS_SERVICE_OK on success).
|
||||
* @param string &$err_msg an error message (empty on success).
|
||||
*
|
||||
* @return a Proxy Ticket, or false on error.
|
||||
* @return string|false a Proxy Ticket, or false on error.
|
||||
*/
|
||||
public function retrievePT($target_service,&$err_code,&$err_msg)
|
||||
{
|
||||
@@ -2686,17 +2676,15 @@ class CAS_Client
|
||||
|
||||
$bad_response = false;
|
||||
|
||||
if ( !$bad_response ) {
|
||||
// create new DOMDocument object
|
||||
$dom = new DOMDocument();
|
||||
// Fix possible whitspace problems
|
||||
$dom->preserveWhiteSpace = false;
|
||||
// read the response of the CAS server into a DOM object
|
||||
if ( !($dom->loadXML($cas_response))) {
|
||||
phpCAS::trace('dom->loadXML() failed');
|
||||
// read failed
|
||||
$bad_response = true;
|
||||
}
|
||||
// create new DOMDocument object
|
||||
$dom = new DOMDocument();
|
||||
// Fix possible whitspace problems
|
||||
$dom->preserveWhiteSpace = false;
|
||||
// read the response of the CAS server into a DOM object
|
||||
if ( !($dom->loadXML($cas_response))) {
|
||||
phpCAS::trace('dom->loadXML() failed');
|
||||
// read failed
|
||||
$bad_response = true;
|
||||
}
|
||||
|
||||
if ( !$bad_response ) {
|
||||
@@ -2784,7 +2772,7 @@ class CAS_Client
|
||||
* failure).
|
||||
* @param string &$err_msg an error message, filled on failure.
|
||||
*
|
||||
* @return true on success, false otherwise (in this later case, $err_msg
|
||||
* @return bool true on success, false otherwise (in this later case, $err_msg
|
||||
* contains an error message).
|
||||
*/
|
||||
private function _readURL($url, &$headers, &$body, &$err_msg)
|
||||
@@ -2840,7 +2828,7 @@ class CAS_Client
|
||||
/**
|
||||
* This method is used to build the SAML POST body sent to /samlValidate URL.
|
||||
*
|
||||
* @return the SOAP-encased SAMLP artifact (the ticket).
|
||||
* @return string the SOAP-encased SAMLP artifact (the ticket).
|
||||
*/
|
||||
private function _buildSAMLPayload()
|
||||
{
|
||||
@@ -2962,7 +2950,7 @@ class CAS_Client
|
||||
* @param string &$output the output of the service (also used to give an error
|
||||
* message on failure).
|
||||
*
|
||||
* @return true on success, false otherwise (in this later case, $err_code
|
||||
* @return bool true on success, false otherwise (in this later case, $err_code
|
||||
* gives the reason why it failed and $output contains an error message).
|
||||
*/
|
||||
public function serviceWeb($url,&$err_code,&$output)
|
||||
@@ -3011,7 +2999,7 @@ class CAS_Client
|
||||
* @param string &$pt the Proxy Ticket (PT) retrieved from the CAS
|
||||
* server to access the URL on success, false on error).
|
||||
*
|
||||
* @return object an IMAP stream on success, false otherwise (in this later
|
||||
* @return object|false an IMAP stream on success, false otherwise (in this later
|
||||
* case, $err_code gives the reason why it failed and $err_msg contains an
|
||||
* error message).
|
||||
*/
|
||||
@@ -3157,17 +3145,18 @@ class CAS_Client
|
||||
*
|
||||
* @param string &$validate_url the url of the reponse
|
||||
* @param string &$text_response the text of the repsones
|
||||
* @param string &$tree_response the domxml tree of the respones
|
||||
* @param DOMElement &$tree_response the domxml tree of the respones
|
||||
* @param bool $renew true to force the authentication with the CAS server
|
||||
*
|
||||
* @return bool true when successfull and issue a CAS_AuthenticationException
|
||||
* and false on an error
|
||||
*
|
||||
* @throws CAS_AuthenticationException
|
||||
*/
|
||||
public function validateCAS20(&$validate_url,&$text_response,&$tree_response, $renew=false)
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
phpCAS::trace($text_response);
|
||||
$result = false;
|
||||
// build the URL to validate the ticket
|
||||
if ($this->getAllowedProxyChains()->isProxyingAllowed()) {
|
||||
$validate_url = $this->getServerProxyValidateURL().'&ticket='
|
||||
@@ -3196,7 +3185,6 @@ class CAS_Client
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
true/*$no_response*/
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
|
||||
// create new DOMDocument object
|
||||
@@ -3212,7 +3200,6 @@ class CAS_Client
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
false/*$no_response*/, true/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if ( !($tree_response = $dom->documentElement) ) {
|
||||
// read the root node of the XML tree
|
||||
// read failed
|
||||
@@ -3220,7 +3207,6 @@ class CAS_Client
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
false/*$no_response*/, true/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if ($tree_response->localName != 'serviceResponse') {
|
||||
// insure that tag name is 'serviceResponse'
|
||||
// bad root node
|
||||
@@ -3228,7 +3214,6 @@ class CAS_Client
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
false/*$no_response*/, true/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
} else if ( $tree_response->getElementsByTagName("authenticationFailure")->length != 0) {
|
||||
// authentication failed, extract the error code and message and throw exception
|
||||
$auth_fail_list = $tree_response
|
||||
@@ -3240,7 +3225,6 @@ class CAS_Client
|
||||
$auth_fail_list->item(0)->getAttribute('code')/*$err_code*/,
|
||||
trim($auth_fail_list->item(0)->nodeValue)/*$err_msg*/
|
||||
);
|
||||
$result = false;
|
||||
} else if ($tree_response->getElementsByTagName("authenticationSuccess")->length != 0) {
|
||||
// authentication succeded, extract the user name
|
||||
$success_elements = $tree_response
|
||||
@@ -3251,7 +3235,6 @@ class CAS_Client
|
||||
$this, 'Ticket not validated', $validate_url,
|
||||
false/*$no_response*/, true/*$bad_response*/, $text_response
|
||||
);
|
||||
$result = false;
|
||||
} else {
|
||||
$this->_setUser(
|
||||
trim(
|
||||
@@ -3276,7 +3259,6 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
} else {
|
||||
$result = true;
|
||||
}
|
||||
@@ -3287,11 +3269,10 @@ class CAS_Client
|
||||
false/*$no_response*/, true/*$bad_response*/,
|
||||
$text_response
|
||||
);
|
||||
$result = false;
|
||||
}
|
||||
if ($result) {
|
||||
$this->_renameSession($this->getTicket());
|
||||
}
|
||||
|
||||
$this->_renameSession($this->getTicket());
|
||||
|
||||
// at this step, Ticket has been validated and $this->_user has been set,
|
||||
|
||||
phpCAS::traceEnd($result);
|
||||
@@ -3303,7 +3284,7 @@ class CAS_Client
|
||||
* This method will parse the DOM and pull out the attributes from the XML
|
||||
* payload and put them into an array, then put the array into the session.
|
||||
*
|
||||
* @param string $success_elements payload of the response
|
||||
* @param DOMNodeList $success_elements payload of the response
|
||||
*
|
||||
* @return bool true when successfull, halt otherwise by calling
|
||||
* CAS_Client::_authError().
|
||||
@@ -3334,7 +3315,7 @@ class CAS_Client
|
||||
&& is_callable($this->_casAttributeParserCallbackFunction)
|
||||
) {
|
||||
array_unshift($this->_casAttributeParserCallbackArgs, $success_elements->item(0));
|
||||
phpCas :: trace("Calling attritubeParser callback");
|
||||
phpCAS :: trace("Calling attritubeParser callback");
|
||||
$extra_attributes = call_user_func_array(
|
||||
$this->_casAttributeParserCallbackFunction,
|
||||
$this->_casAttributeParserCallbackArgs
|
||||
@@ -3342,11 +3323,11 @@ class CAS_Client
|
||||
} elseif ( $success_elements->item(0)->getElementsByTagName("attributes")->length != 0) {
|
||||
$attr_nodes = $success_elements->item(0)
|
||||
->getElementsByTagName("attributes");
|
||||
phpCas :: trace("Found nested jasig style attributes");
|
||||
phpCAS :: trace("Found nested jasig style attributes");
|
||||
if ($attr_nodes->item(0)->hasChildNodes()) {
|
||||
// Nested Attributes
|
||||
foreach ($attr_nodes->item(0)->childNodes as $attr_child) {
|
||||
phpCas :: trace(
|
||||
phpCAS :: trace(
|
||||
"Attribute [".$attr_child->localName."] = "
|
||||
.$attr_child->nodeValue
|
||||
);
|
||||
@@ -3373,7 +3354,7 @@ class CAS_Client
|
||||
// </cas:authenticationSuccess>
|
||||
// </cas:serviceResponse>
|
||||
//
|
||||
phpCas :: trace("Testing for rubycas style attributes");
|
||||
phpCAS :: trace("Testing for rubycas style attributes");
|
||||
$childnodes = $success_elements->item(0)->childNodes;
|
||||
foreach ($childnodes as $attr_node) {
|
||||
switch ($attr_node->localName) {
|
||||
@@ -3383,7 +3364,7 @@ class CAS_Client
|
||||
break;
|
||||
default:
|
||||
if (strlen(trim($attr_node->nodeValue))) {
|
||||
phpCas :: trace(
|
||||
phpCAS :: trace(
|
||||
"Attribute [".$attr_node->localName."] = ".$attr_node->nodeValue
|
||||
);
|
||||
$this->_addAttributeToArray(
|
||||
@@ -3425,13 +3406,13 @@ class CAS_Client
|
||||
&& $firstAttr->hasAttribute('name')
|
||||
&& $firstAttr->hasAttribute('value')
|
||||
) {
|
||||
phpCas :: trace("Found Name-Value style attributes");
|
||||
phpCAS :: trace("Found Name-Value style attributes");
|
||||
// Nested Attributes
|
||||
foreach ($attr_nodes as $attr_node) {
|
||||
if ($attr_node->hasAttribute('name')
|
||||
&& $attr_node->hasAttribute('value')
|
||||
) {
|
||||
phpCas :: trace(
|
||||
phpCAS :: trace(
|
||||
"Attribute [".$attr_node->getAttribute('name')
|
||||
."] = ".$attr_node->getAttribute('value')
|
||||
);
|
||||
@@ -3519,14 +3500,13 @@ class CAS_Client
|
||||
* This method returns the URL of the current request (without any ticket
|
||||
* CGI parameter).
|
||||
*
|
||||
* @return The URL
|
||||
* @return string The URL
|
||||
*/
|
||||
public function getURL()
|
||||
{
|
||||
phpCAS::traceBegin();
|
||||
// the URL is built when needed only
|
||||
if ( empty($this->_url) ) {
|
||||
$final_uri = '';
|
||||
// remove the ticket if present in the URL
|
||||
$final_uri = ($this->_isHttps()) ? 'https' : 'http';
|
||||
$final_uri .= '://';
|
||||
@@ -3570,13 +3550,12 @@ class CAS_Client
|
||||
|
||||
|
||||
/**
|
||||
* Try to figure out the phpCas client URL with possible Proxys / Ports etc.
|
||||
* Try to figure out the phpCAS client URL with possible Proxys / Ports etc.
|
||||
*
|
||||
* @return string Server URL with domain:port
|
||||
*/
|
||||
private function _getClientUrl()
|
||||
{
|
||||
$server_url = '';
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||
// explode the host list separated by comma and use the first host
|
||||
$hosts = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
|
||||
@@ -3657,7 +3636,7 @@ class CAS_Client
|
||||
* @param string $url base url to add the query params to
|
||||
* @param string $query params in query form with & separated
|
||||
*
|
||||
* @return url with query params
|
||||
* @return string url with query params
|
||||
*/
|
||||
private function _buildQueryUrl($url, $query)
|
||||
{
|
||||
@@ -3682,7 +3661,7 @@ class CAS_Client
|
||||
phpCAS :: trace("Killing session: ". session_id());
|
||||
session_destroy();
|
||||
// set up a new session, of name based on the ticket
|
||||
$session_id = preg_replace('/[^a-zA-Z0-9\-]/', '', $ticket);
|
||||
$session_id = $this->_sessionIdForTicket($ticket);
|
||||
phpCAS :: trace("Starting session: ". $session_id);
|
||||
session_id($session_id);
|
||||
session_start();
|
||||
@@ -3701,6 +3680,41 @@ class CAS_Client
|
||||
phpCAS::traceEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Answer a valid session-id given a CAS ticket.
|
||||
*
|
||||
* The output must be deterministic to allow single-log-out when presented with
|
||||
* the ticket to log-out.
|
||||
*
|
||||
*
|
||||
* @param string $ticket name of the ticket
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _sessionIdForTicket($ticket)
|
||||
{
|
||||
// Hash the ticket to ensure that the value meets the PHP 7.1 requirement
|
||||
// that session-ids have a length between 22 and 256 characters.
|
||||
return hash('sha256', $this->_sessionIdSalt . $ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a salt/seed for the session-id hash to make it harder to guess.
|
||||
*
|
||||
* @var string $_sessionIdSalt
|
||||
*/
|
||||
private $_sessionIdSalt = '';
|
||||
|
||||
/**
|
||||
* Set a salt/seed for the session-id hash to make it harder to guess.
|
||||
*
|
||||
* @param string $salt
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSessionIdSalt($salt) {
|
||||
$this->_sessionIdSalt = (string)$salt;
|
||||
}
|
||||
|
||||
// ########################################################################
|
||||
// AUTHENTICATION ERROR HANDLING
|
||||
@@ -3724,10 +3738,10 @@ class CAS_Client
|
||||
private function _authError(
|
||||
$failure,
|
||||
$cas_url,
|
||||
$no_response,
|
||||
$bad_response='',
|
||||
$no_response=false,
|
||||
$bad_response=false,
|
||||
$cas_response='',
|
||||
$err_code='',
|
||||
$err_code=-1,
|
||||
$err_msg=''
|
||||
) {
|
||||
phpCAS::traceBegin();
|
||||
@@ -3751,7 +3765,7 @@ class CAS_Client
|
||||
break;
|
||||
case CAS_VERSION_2_0:
|
||||
case CAS_VERSION_3_0:
|
||||
if ( empty($err_code) ) {
|
||||
if ( $err_code === -1 ) {
|
||||
phpCAS::trace('Reason: no CAS error');
|
||||
} else {
|
||||
phpCAS::trace(
|
||||
@@ -3790,7 +3804,7 @@ class CAS_Client
|
||||
*
|
||||
* @param String $nodeURL The node URL.
|
||||
*
|
||||
* @return string hostname
|
||||
* @return int hostname
|
||||
*
|
||||
*/
|
||||
private function _getNodeType($nodeURL)
|
||||
@@ -3931,5 +3945,3 @@ class CAS_Client
|
||||
|
||||
/** @} */
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -74,7 +74,6 @@ class CAS_CookieJar
|
||||
|
||||
$cookies = $this->parseCookieHeaders($response_headers, $defaultDomain);
|
||||
|
||||
// var_dump($cookies);
|
||||
foreach ($cookies as $cookie) {
|
||||
// Enforce the same-origin policy by verifying that the cookie
|
||||
// would match the url that is setting it
|
||||
@@ -308,7 +307,7 @@ class CAS_CookieJar
|
||||
* Answer true if cookie is applicable to a target.
|
||||
*
|
||||
* @param array $cookie An array of cookie attributes.
|
||||
* @param array $target An array of URL attributes as generated by parse_url().
|
||||
* @param array|false $target An array of URL attributes as generated by parse_url().
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
|
||||
@@ -53,9 +53,9 @@ implements CAS_Exception
|
||||
* with our tests.
|
||||
*
|
||||
* @param string $message Message Text
|
||||
* @param string $code Error code
|
||||
* @param int $code Error code
|
||||
*
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
public function __construct ($message = 'Terminate Gracefully', $code = 0)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ abstract class CAS_PGTStorage_AbstractStorage
|
||||
* This virtual method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ abstract class CAS_PGTStorage_AbstractStorage
|
||||
* This virtual method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
@@ -136,7 +136,7 @@ abstract class CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method returns an error message set by PGTStorage::setErrorMessage().
|
||||
*
|
||||
* @return an error message when set by PGTStorage::setErrorMessage(), FALSE
|
||||
* @return string an error message when set by PGTStorage::setErrorMessage(), FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* @deprecated not used.
|
||||
@@ -161,7 +161,7 @@ abstract class CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method tells if the storage has already been intialized.
|
||||
*
|
||||
* @return a boolean
|
||||
* @return bool
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
@@ -206,7 +206,7 @@ abstract class CAS_PGTStorage_AbstractStorage
|
||||
*
|
||||
* @param string $pgt_iou the PGT iou
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @note Should never be called.
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method returns the PDO object to use for database interactions.
|
||||
*
|
||||
* @return the PDO object
|
||||
* @return PDO object
|
||||
*/
|
||||
private function _getPdo()
|
||||
{
|
||||
@@ -71,17 +71,17 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
private $_dsn;
|
||||
private $_username;
|
||||
private $_password;
|
||||
private $_table_options;
|
||||
private $_driver_options;
|
||||
|
||||
/**
|
||||
* the table to use for storing/retrieving pgt's
|
||||
* @var string the table to use for storing/retrieving pgt's
|
||||
*/
|
||||
private $_table;
|
||||
|
||||
/**
|
||||
* This method returns the table to use when storing/retrieving PGT's
|
||||
*
|
||||
* @return the name of the pgt storage table.
|
||||
* @return string the name of the pgt storage table.
|
||||
*/
|
||||
private function _getTable()
|
||||
{
|
||||
@@ -96,7 +96,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @return string an informational string.
|
||||
*/
|
||||
public function getStorageType()
|
||||
{
|
||||
@@ -107,7 +107,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @return string an informational string.
|
||||
* @public
|
||||
*/
|
||||
public function getStorageInfo()
|
||||
@@ -248,7 +248,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method returns the query used to create a pgt storage table
|
||||
*
|
||||
* @return the create table SQL, no bind params in query
|
||||
* @return string the create table SQL, no bind params in query
|
||||
*/
|
||||
protected function createTableSql()
|
||||
{
|
||||
@@ -259,7 +259,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method returns the query used to store a pgt
|
||||
*
|
||||
* @return the store PGT SQL, :pgt and :pgt_iou are the bind params contained
|
||||
* @return string the store PGT SQL, :pgt and :pgt_iou are the bind params contained
|
||||
* in the query
|
||||
*/
|
||||
protected function storePgtSql()
|
||||
@@ -272,7 +272,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns the query used to retrieve a pgt. the first column
|
||||
* of the first row should contain the pgt
|
||||
*
|
||||
* @return the retrieve PGT SQL, :pgt_iou is the only bind param contained
|
||||
* @return string the retrieve PGT SQL, :pgt_iou is the only bind param contained
|
||||
* in the query
|
||||
*/
|
||||
protected function retrievePgtSql()
|
||||
@@ -283,7 +283,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
/**
|
||||
* This method returns the query used to delete a pgt.
|
||||
*
|
||||
* @return the delete PGT SQL, :pgt_iou is the only bind param contained in
|
||||
* @return string the delete PGT SQL, :pgt_iou is the only bind param contained in
|
||||
* the query
|
||||
*/
|
||||
protected function deletePgtSql()
|
||||
@@ -387,7 +387,7 @@ class CAS_PGTStorage_Db extends CAS_PGTStorage_AbstractStorage
|
||||
*
|
||||
* @param string $pgt_iou the PGT iou
|
||||
*
|
||||
* @return the corresponding PGT, or FALSE on error
|
||||
* @return string|false the corresponding PGT, or FALSE on error
|
||||
*/
|
||||
public function read($pgt_iou)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns the name of the directory where PGT's should be stored
|
||||
* on the filesystem.
|
||||
*
|
||||
* @return the name of a directory (with leading and trailing '/')
|
||||
* @return string the name of a directory (with leading and trailing '/')
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns an informational string giving the type of storage
|
||||
* used by the object (used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @return string an informational string.
|
||||
* @public
|
||||
*/
|
||||
function getStorageType()
|
||||
@@ -90,7 +90,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
* This method returns an informational string giving informations on the
|
||||
* parameters of the storage.(used for debugging purposes).
|
||||
*
|
||||
* @return an informational string.
|
||||
* @return string an informational string.
|
||||
* @public
|
||||
*/
|
||||
function getStorageInfo()
|
||||
@@ -122,7 +122,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
$path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
|
||||
}
|
||||
// check that the path is an absolute path
|
||||
if (getenv("OS")=="Windows_NT") {
|
||||
if (getenv("OS")=="Windows_NT" || strtoupper(substr(PHP_OS,0,3)) == 'WIN') {
|
||||
|
||||
if (!preg_match('`^[a-zA-Z]:`', $path)) {
|
||||
phpCAS::error('an absolute path is needed for PGT storage to file');
|
||||
@@ -174,7 +174,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
*
|
||||
* @param string $pgt_iou the PGT iou.
|
||||
*
|
||||
* @return a filename
|
||||
* @return string a filename
|
||||
* @private
|
||||
*/
|
||||
function getPGTIouFilename($pgt_iou)
|
||||
@@ -227,7 +227,7 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
*
|
||||
* @param string $pgt_iou the PGT iou
|
||||
*
|
||||
* @return the corresponding PGT, or FALSE on error
|
||||
* @return string|false the corresponding PGT, or FALSE on error
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
@@ -258,4 +258,4 @@ class CAS_PGTStorage_File extends CAS_PGTStorage_AbstractStorage
|
||||
/** @} */
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -180,7 +180,7 @@ CAS_ProxiedService_Abstract implements CAS_ProxiedService_Http
|
||||
/**
|
||||
* The response status code.
|
||||
*
|
||||
* @var string $_responseStatusCode;
|
||||
* @var int $_responseStatusCode;
|
||||
*/
|
||||
private $_responseStatusCode = '';
|
||||
|
||||
@@ -266,7 +266,7 @@ CAS_ProxiedService_Abstract implements CAS_ProxiedService_Http
|
||||
*
|
||||
* @param array $responseHeaders response header to extract a redirect from
|
||||
*
|
||||
* @return string or null
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getRedirectUrl(array $responseHeaders)
|
||||
{
|
||||
|
||||
@@ -248,6 +248,7 @@ extends CAS_ProxiedService_Abstract
|
||||
* Answer the IMAP stream
|
||||
*
|
||||
* @return resource
|
||||
* @throws CAS_OutOfSequenceException if stream is not opened yet
|
||||
*/
|
||||
public function getStream ()
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ class CAS_ProxyChain_AllowedList
|
||||
*
|
||||
* @param array $list List of proxies from the proxy ticket validation.
|
||||
*
|
||||
* @return if any chain fully matches the supplied list
|
||||
* @return bool if any chain fully matches the supplied list
|
||||
*/
|
||||
public function contains(array $list)
|
||||
{
|
||||
|
||||
@@ -322,6 +322,7 @@ implements CAS_Request_RequestInterface
|
||||
*
|
||||
* @return int
|
||||
* @throws CAS_OutOfSequenceException If called before the Request has been sent.
|
||||
* @throws CAS_Request_Exception if the response did not contain a status code
|
||||
*/
|
||||
public function getResponseStatusCode ()
|
||||
{
|
||||
|
||||
@@ -80,7 +80,8 @@ implements CAS_Request_MultiRequestInterface
|
||||
/**
|
||||
* Retrieve the number of requests added to this batch.
|
||||
*
|
||||
* @return number of request elements
|
||||
* @return int number of request elements
|
||||
* @throws CAS_OutOfSequenceException if the request has already been sent
|
||||
*/
|
||||
public function getNumRequests()
|
||||
{
|
||||
|
||||
@@ -97,7 +97,7 @@ implements CAS_Request_RequestInterface
|
||||
* This method should NOT be used outside of the CurlRequest or the
|
||||
* CurlMultiRequest.
|
||||
*
|
||||
* @return resource The cURL handle on success, false on failure
|
||||
* @return resource|false The cURL handle on success, false on failure
|
||||
*/
|
||||
public function initAndConfigure()
|
||||
{
|
||||
@@ -187,10 +187,10 @@ implements CAS_Request_RequestInterface
|
||||
/**
|
||||
* Internal method for capturing the headers from a curl request.
|
||||
*
|
||||
* @param handle $ch handle of curl
|
||||
* @param resource $ch handle of curl
|
||||
* @param string $header header
|
||||
*
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
private function _curlReadHeaders ($ch, $header)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ interface CAS_Request_MultiRequestInterface
|
||||
/**
|
||||
* Retrieve the number of requests added to this batch.
|
||||
*
|
||||
* @return number of request elements
|
||||
* @return int number of request elements
|
||||
*/
|
||||
public function getNumRequests ();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Description of phpCAS 1.3.5 library import
|
||||
Description of phpCAS 1.3.7 library import
|
||||
|
||||
* downloaded from http://downloads.jasig.org/cas-clients/php/current/
|
||||
* applied patch https://github.com/apereo/phpCAS/pull/247 for PHP 7.2 compatibility (MDL-60280)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<location>CAS</location>
|
||||
<name>CAS</name>
|
||||
<license>Apache</license>
|
||||
<version>1.3.5</version>
|
||||
<version>1.3.7</version>
|
||||
<licenseversion>2.0</licenseversion>
|
||||
</library>
|
||||
</libraries>
|
||||
|
||||
Reference in New Issue
Block a user