initial setup of framework code
[cacert-mgr.git] / manager / library / plugins / plugin.forceauth.php
1 <?php
2 /**
3 * @author markus
4 * $Id: plugin.forceauth.php 40 2009-12-21 09:40:43Z markus $
5 */
6 class ForceAuth extends Zend_Controller_Plugin_Abstract {
7 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
8 $session = Zend_Registry::get('session');
9
10 if (in_array($request->getControllerName(), array('login', 'error', 'js', 'img', 'css')))
11 return;
12
13 if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
14 $fc = Zend_Controller_Front::getInstance();
15
16 $response = $fc->getResponse();
17 $response->canSendHeaders(true);
18
19 $response->setHeader('Location', 'login', true);
20 $response->setHeader('Status', '301', true);
21 Log::Log()->debug('redirected to login');
22
23 $request->setModuleName('default')
24 ->setControllerName('login')
25 ->setActionName('index')
26 ->setDispatched(false);
27 }
28 }
29 }