public function preDispatch() { if ($this->_getParam('applicationAssetsVersion')) { if (Kwf_Assets_Dispatcher::getAssetsVersion() != $this->_getParam('applicationAssetsVersion')) { $this->_forward('json-wrong-version', 'error', 'kwf_controller_action_error'); return; } } $this->_validateSessionToken(); $allowed = false; if ($this->_getUserRole() == 'cli') { $allowed = true; } else { $acl = Zend_Registry::get('acl'); $resource = $this->getRequest()->getResourceName(); if (!$acl->has($resource)) { throw new Kwf_Exception_NotFound(); } else { if ($this->_getAuthData()) { $allowed = $acl->isAllowedUser($this->_getAuthData(), $resource, 'view'); } else { $allowed = $acl->isAllowed($this->_getUserRole(), $resource, 'view'); } } } if (!$allowed) { $params = array('resource' => $resource, 'role' => $this->_getUserRole()); $this->_forward('json-login', 'login', 'kwf_controller_action_user', $params); } parent::preDispatch(); }
public function preDispatch() { if ($this->_getParam('applicationAssetsVersion') && $this->getHelper('ViewRenderer')->isJson()) { if (Kwf_Assets_Dispatcher::getAssetsVersion() != $this->_getParam('applicationAssetsVersion')) { $this->_forward('json-wrong-version', 'error', 'kwf_controller_action_error'); return; } } $this->_validateSessionToken(); $t = microtime(true); $allowed = $this->_isAllowedResource(); if ($allowed) { $allowed = $this->_isAllowed($this->_getAuthData()); } if (!$allowed) { $params = array('role' => $this->_getUserRole()); if ($this->getHelper('ViewRenderer')->isJson()) { $this->_forward('json-login', 'login', 'kwf_controller_action_user', $params); } else { $params = array('location' => $this->getRequest()->getBaseUrl() . '/' . ltrim($this->getRequest()->getPathInfo(), '/')); $this->_forward('index', 'login', 'kwf_controller_action_user', $params); } } Kwf_Benchmark::subCheckpoint('check acl', microtime(true) - $t); }
public function jsonWrongVersionAction() { $this->view->wrongversion = true; $this->view->success = false; $this->view->assetsVersion = Kwf_Assets_Dispatcher::getAssetsVersion(); $this->getResponse()->setRawHeader('HTTP/1.0 428 Precondition Required'); $this->getResponse()->setHttpResponseCode(428); }
public function getContents($language) { $ret = "if (typeof Kwf == 'undefined') Kwf = {};" . "Kwf.application = { assetsVersion: '" . Kwf_Assets_Dispatcher::getAssetsVersion() . "' };\n"; return $ret; }
public function getPackageUrl($ext, $language) { return Kwf_Setup::getBaseUrl() . '/assets/dependencies/' . get_class($this) . '/' . $this->toUrlParameter() . '/' . $language . '/' . $ext . '?v=' . Kwf_Assets_Dispatcher::getAssetsVersion(); }