Example #1
0
 /**
  * _default 
  * 
  * @param mixed $request Request to use
  *
  * @access public
  * @return void
  */
 public function _default($request)
 {
     $subject = \Native5\Identity\SecurityUtils::getSubject();
     if ($subject->isAuthenticated()) {
         $this->_response->redirectTo('dashboard');
         $this->_response->send();
     }
     $this->_response = new \Native5\Route\HttpResponse('none', new \Native5\UI\TwigRenderer('login.tmpl'));
     $this->_response->addHeader('Cache-Control: no-cache, must-revalidate');
     $this->_response->setBody(array());
 }
Example #2
0
 /**
  * Default Handler for Logout Controller 
  * 
  * @param mixed $request Request to process.
  *
  * @access public
  * @return void
  */
 public function _default($request)
 {
     $subject = \Native5\Identity\SecurityUtils::getSubject();
     $subject->logout();
     \Native5\Sessions\WebSessionManager::resetActiveSession();
     $this->_response = new \Native5\Route\HttpResponse();
     $this->_response->redirectTo('./login');
     //$idenService = new \Native5\Services\Identity\RemoteAuthenticationService();
     //$idenService->onLogout();
     //WebSessionManager::resetActiveSession();
     //$this->_response = new \Native5\Route\HttpResponse();
     //$this->_response->redirectTo('./');
 }
Example #3
0
 /**
  * _default 
  * 
  * @param mixed $request The incoming request 
  *
  * @access public
  * @return void
  */
 public function _default($request)
 {
     global $logger;
     global $app;
     $subject = SecurityUtils::getSubject();
     $logger->debug('Authentication Status ' . print_r($subject, 1));
     if ($subject->isAuthenticated() === true) {
         $this->_response->redirectTo('dashboard');
     } else {
         $token = new UsernamePasswordToken($request->getParam('username'), $request->getParam('password'));
         try {
             $subject->login($token);
             $this->_response->redirectTo('dashboard');
         } catch (AuthenticationException $aex) {
             $this->_handleFailedAuthentication($subject, $token, $aex);
         }
     }
 }
 private function __setUser()
 {
     // Create the (helper) user object from the authenticated subject if present
     $subject = \Native5\Identity\SecurityUtils::getSubject();
     if ($subject->isAuthenticated()) {
         $this->user = \Akzo\User\Service::getInstance()->getUser($subject->getPrincipal()['username'], $subject);
     }
 }
Example #5
0
 /**
  * init 
  * 
  * @param string $configFile Configuration with which to initialize an app with
  *
  * @static
  * @access public
  * @return void
  */
 public static function init($configFile = 'config/settings.yml', $localConfigFile = 'config/settings.local.yml')
 {
     // Check what php SAPI is being used
     self::$_cli = false;
     if (strcmp(php_sapi_name(), 'cli') === 0) {
         self::$_cli = true;
     }
     // Initialize application services, Store application Object as a global
     // Services are available from global app.
     $GLOBALS['app'] = $app = new self();
     $GLOBALS['logger'] = LoggerFactory::instance()->getLogger();
     $GLOBALS['routeLogger'] = LoggerFactory::instance()->getLogger();
     $configFactory = new ConfigurationFactory($configFile, $localConfigFile);
     $app->_config = $configFactory->getConfig();
     $logFolder = getcwd() . '/logs';
     if (!file_exists($logFolder)) {
         if (!mkdir($logFolder)) {
             $logFolder = sys_get_temp_dir() . '/logs';
             if (!file_exists($logFolder) && !mkdir($logFolder)) {
                 die('Insufficient privileges to create logs folder in application directory, or temp path, exiting');
             }
         }
     }
     $file = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-debug.log';
     $GLOBALS['logger']->addHandler($file, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()]);
     $analyticsFile = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-analytics.log';
     $GLOBALS['routeLogger']->addHandler($analyticsFile, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()], 'analytics');
     if (!self::$_cli) {
         $sessionManager = new WebSessionManager();
         $sessionManager->startSession(null, true);
         $app->_services['sessions'] = $sessionManager;
         SecurityUtils::setSecurityManager(new DefaultSecurityManager());
         $app->_subject = $app->_getSubjectFromSession($sessionManager->getActiveSession());
         $app->_services['routing'] = new RoutingEngine();
     }
     $app->_services['messaging'] = NotificationService::instance();
     return $app;
 }
    /**
     * updateActiveSession 
     * 
     * @access public
     * @return void
     */
    public static function updateActiveSession()
    {
        $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time();

        // Update the session if session is authenticated and multiple logins is disabled
        $app = $GLOBALS['app'];
        if(\Native5\Identity\SecurityUtils::getSubject()->isAuthenticated() && $app->getConfiguration()->isPreventMultipleLogins()) {
            $sessionHash = $app->getSessionManager()->getActiveSession()->getAttribute('sessionHash');
            $authenticator = new \Native5\Services\Identity\RemoteAuthenticationService();
            $authenticator->onAccess($sessionHash);
        }
    }//end updateActiveSession()