3 * Piwik - Open source web analytics
5 * @link http://piwik.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
7 * @version $Id: Controller.php 943 2009-03-01 23:36:36Z matt $
9 * @package Piwik_CASLogin
12 require PIWIK_INCLUDE_PATH . '/plugins/UsersManager/API.php';
13 require PIWIK_INCLUDE_PATH . '/core/View.php';
16 * @package Piwik_CASLogin
18 class Piwik_CASLogin_Controller extends Piwik_Controller
20 public function index()
22 Piwik::redirectToModule('CoreHome');
26 * Configure common view properties
28 * @param Piwik_View $view
30 private function configureView($view)
33 $this->setBasicVariablesView($view);
34 $view->linkTitle = Piwik::getRandomTitle();
36 $enableFramedLogins = Zend_Registry::get('config')->General->enable_framed_logins;
37 $view->enableFramedLogins = $enableFramedLogins;
38 if(!$enableFramedLogins)
40 $view->setXFrameOptions('sameorigin');
42 $view->forceSslLogin = Zend_Registry::get('config')->General->force_ssl_login;
43 // crsf token: don't trust the submitted value; generate/fetch it from session data
44 $view->nonce = Piwik_Nonce::getNonce('Piwik_Login.login');
50 * @param string $messageNoAccess Access error message
51 * @param string $currentUrl Current URL
54 function login($messageNoAccess = null)
56 $view = Piwik_View::factory('login');
57 $view->AccessErrorString = $messageNoAccess;
58 $view->linkTitle = Piwik::getRandomTitle();
59 $view->subTemplate = 'genericForm.tpl';
60 $this->configureView($view);
64 public function redirectToCAS() {
65 // This is simply if we are coming back from CAS.
66 // the actual redirect happens in the authentication class.
67 if(Piwik::getCurrentUserLogin() != 'anonymous') {
68 Piwik::redirectToModule('CoreHome');
72 private function clearSession()
74 /* Note: some browsers don't respect server revokation */
75 $auth = Zend_Registry::get('auth');
76 $auth->setLogin(null);
77 $auth->setTokenAuth(null);
79 $access = Zend_Registry::get('access');
80 $access->reloadAccess($auth);
82 $authCookieName = Zend_Registry::get('config')->General->login_cookie_name;
83 $cookie = new Piwik_Cookie($authCookieName);
86 @Zend_Session::destroy(true);
89 public function logout()
91 phpCAS::logoutWithUrl(Piwik_Url::getCurrentUrlWithoutQueryString() );