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)
{
protected $login = null;
protected $token_auth = null;
+ private static $phpcas_client_called = false;
public function getName()
{
public function authenticate()
{
+ // Make sure Piwik session is started.
+ Session::start();
+
$user = '';
require_once PIWIK_INCLUDE_PATH . '/plugins/CASLogin/CAS/CAS.php';
// 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'],
'',
false
);
+ self::$phpcas_client_called = true;
}
// no SSL validation for the CAS server
{
$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.
)
);
}
-
+
+ // Those methods are required by Piwik API.
+ public function setPassword($password) {}
+ public function setPasswordHash($passwordHash) {}
}