X-Git-Url: https://git.mdrn.pl/piwik-CASLogin.git/blobdiff_plain/237569a1cfdd478618b0ecda78a7ac13548c515f..HEAD:/Auth.php?ds=sidebyside diff --git a/Auth.php b/Auth.php index e9714d1..de6453a 100644 --- a/Auth.php +++ b/Auth.php @@ -18,6 +18,7 @@ use Piwik\Config; use Piwik\Db; use Piwik\Piwik; use Piwik\Plugins\UsersManager\API; +use Piwik\Session; /** * Class that implements an authentication mechanism via CAS (Central Authentication Services) @@ -28,6 +29,7 @@ class Auth implements \Piwik\Auth { protected $login = null; protected $token_auth = null; + private static $phpcas_client_called = false; public function getName() { @@ -38,6 +40,9 @@ class Auth implements \Piwik\Auth public function authenticate() { + // Make sure Piwik session is started. + Session::start(); + $user = ''; require_once PIWIK_INCLUDE_PATH . '/plugins/CASLogin/CAS/CAS.php'; @@ -50,8 +55,7 @@ class Auth implements \Piwik\Auth // The first authenticate() is from the page, and the second is due to an API call. // This checks if there was already a phpcas instance already initialized, otherwize // phpCAS::client() would fail. - global $PHPCAS_CLIENT; - if(!is_object($PHPCAS_CLIENT)) { + if (!self::$phpcas_client_called) { \phpCAS::client( constant( Config::getInstance()->caslogin['protocol'] ), Config::getInstance()->caslogin['host'], @@ -59,6 +63,7 @@ class Auth implements \Piwik\Auth '', false ); + self::$phpcas_client_called = true; } // no SSL validation for the CAS server @@ -133,11 +138,17 @@ class Auth implements \Piwik\Auth { $this->login = $login; } + public function getLogin() { + return $this->login; + } public function setTokenAuth($token_auth) { $this->token_auth = $token_auth; } + public function getTokenAuthSecret() { + return $this->token_auth; + } /** * This method is used to inject user into Piwik's tables. @@ -196,6 +207,9 @@ class Auth implements \Piwik\Auth ) ); } - + + // Those methods are required by Piwik API. + public function setPassword($password) {} + public function setPasswordHash($passwordHash) {} }