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 * @category Piwik_Plugins
13 namespace Piwik\Plugins\CASLogin;
18 use Piwik\Plugins\UsersManager\API;
25 class Controller extends \Piwik\Plugin\Controller
27 public function index()
29 Piwik::redirectToModule('CoreHome');
33 * Configure common view properties
35 * @param Piwik_View $view
37 private function configureView($view)
40 $this->setBasicVariablesView($view);
41 $view->linkTitle = Piwik::getRandomTitle();
43 $enableFramedLogins = Config::getInstance()->General['enable_framed_pages'];
44 $view->enableFramedLogins = $enableFramedLogins;
45 if(!$enableFramedLogins)
47 $view->setXFrameOptions('sameorigin');
49 $view->forceSslLogin = Config::getInstance()->General['force_ssl'];
50 // crsf token: don't trust the submitted value; generate/fetch it from session data
51 $view->nonce = Nonce::getNonce('Piwik_Login.login');
57 * @param string $messageNoAccess Access error message
58 * @param string $currentUrl Current URL
61 function login($messageNoAccess = null)
63 $view = new View('@CASLogin/login');
64 $view->AccessErrorString = $messageNoAccess;
65 $view->linkTitle = Piwik::getRandomTitle();
66 $config = Config::getInstance()->caslogin;
67 $view->loginImage = isset($config['loginimage']) ? $config['loginimage'] : '';
68 $view->subTemplate = 'genericForm.tpl';
69 $this->configureView($view);
73 public function redirectToCAS() {
74 // This is simply if we are coming back from CAS.
75 // the actual redirect happens in the authentication class.
76 if(Piwik::getCurrentUserLogin() != 'anonymous') {
77 Piwik::redirectToModule('CoreHome');
81 private function clearSession()
83 /* Note: some browsers don't respect server revokation */
84 $auth = Zend_Registry::get('auth');
85 $auth->setLogin(null);
86 $auth->setTokenAuth(null);
88 $access = Zend_Registry::get('access');
89 $access->reloadAccess($auth);
91 $authCookieName = Zend_Registry::get('config')->General->login_cookie_name;
92 $cookie = new Piwik_Cookie($authCookieName);
95 @Zend_Session::destroy(true);
98 public function logout()
100 \phpCAS::logoutWithUrl(Url::getCurrentUrlWithoutQueryString() );