Пример #1
0
 /**
  * Methode to call to run interceptor()
  */
 function run()
 {
     $user = $this->userSession->getUser();
     if (is_null($user)) {
         return;
     }
     if ($this->isLoggedIn || $remote) {
         $respons = $this->service->checkUserAllowances($user);
         if ($respons->isDenied()) {
             $uid = $user->getUID();
             //=============================
             $this->userSession->logout();
             //=============================
             $remote = GKHelper::isRemote();
             $this->denyLogger->write("[ts=" . date("YmdHis") . "]" . "[uid=" . $respons->getUid() . "][cause=" . $respons->getCause() . "][groups=" . $respons->getGroup() . "][IP=" . $this->getIPAddress() . "[remote=" . ($remote ? 1 : 0) . "]");
             if ($remote) {
                 $this->denyOnRemote($respons);
             } else {
                 if (!$respons->isEmitted()) {
                     $this->denyOnWeb($respons);
                 }
             }
         }
     }
 }
Пример #2
0
 public function __construct(array $urlParams = array())
 {
     parent::__construct('gatekeeper', $urlParams);
     $container = $this->getContainer();
     // Hooks
     $container->registerService('GateKeeperHooks', function ($c) {
         return new \OCA\GateKeeper\Hooks\GateKeeperHooks($c->query('GateKeeperService'), $c->query('Logger'));
     });
     // Service
     $container->registerService('GateKeeperService', function ($c) {
         return new \OCA\GateKeeper\Service\GateKeeperService($c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'mode'), $c->query('ServerContainer')->getSession(), $c->query('AccessObjectMapper'), $c->query('GroupManager'), GKHelper::isRemote(), $c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'refresh_delay'));
     });
     // Mapper
     $container->registerService('AccessObjectMapper', function ($c) {
         return new \OCA\GateKeeper\Db\AccessObjectMapper($c->query('ServerContainer')->getDb());
     });
     // groupManager
     $container->registerService('GroupManager', function ($c) {
         return \OC_Group::getManager();
     });
     // - logger -
     $container->registerService('Logger', function ($c) {
         return $c->query('ServerContainer')->getLogger();
     });
     $container->registerService('Interceptor', function ($c) {
         return new \OCA\GateKeeper\AppInfo\Interceptor($c->query('ServerContainer')->getUserSession(), \OC_User::isLoggedIn(), $c->query('GateKeeperService'), $c->query('L10N'), $c->query('DenyLogger'));
     });
     $container->registerService('L10N', function ($c) {
         return $c->query('ServerContainer')->getL10N($c->query('AppName'));
     });
     $container->registerService('SettingsController', function ($c) {
         return new \OCA\GateKeeper\Controller\SettingsController($c->query('Request'), $c->query('ServerContainer')->getAppConfig(), $c->query('AccessObjectMapper'), $c->query('GroupManager'));
     });
     $container->registerService('DenyLoggerFactory', function ($c) {
         return new \OCA\GateKeeper\Lib\DenyLoggerFactory($c->query('ServerContainer')->getAppConfig());
     });
     $container->registerService('DenyLogger', function ($c) {
         return $c->query('DenyLoggerFactory')->getInstance();
     });
 }