Esempio n. 1
0
 /**
  * @param ActionEvent $actionEvent
  */
 public function onRoute(ActionEvent $actionEvent)
 {
     if ($this->authorizationService->isGranted($actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME), $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE))) {
         return;
     }
     $actionEvent->stopPropagation(true);
     throw new UnauthorizedException();
 }
Esempio n. 2
0
 /**
  * @param ActionEvent $actionEvent
  */
 public function onRoute(ActionEvent $actionEvent)
 {
     $messageName = $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME);
     if ($this->authorizationService->isGranted($messageName, $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE))) {
         return;
     }
     $actionEvent->stopPropagation(true);
     if (!$this->exposeEventMessageName) {
         $messageName = '';
     }
     throw new UnauthorizedException($messageName);
 }
Esempio n. 3
0
 /**
  * @param ActionEvent $actionEvent
  */
 public function onFinalize(ActionEvent $actionEvent)
 {
     $deferred = $actionEvent->getParam(self::EVENT_PARAM_DEFERRED);
     if ($deferred instanceof Deferred) {
         $deferred->promise()->done(function ($result) use($actionEvent, $deferred) {
             if (!$this->authorizationService->isGranted($actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME), $result)) {
                 $actionEvent->stopPropagation(true);
                 throw new UnauthorizedException();
             }
         });
     } elseif (!$this->authorizationService->isGranted($actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME))) {
         $actionEvent->stopPropagation(true);
         throw new UnauthorizedException();
     }
 }
 /**
  * @param ActionEvent $actionEvent
  * @throws UnauthorizedException
  */
 public function onFinalize(ActionEvent $actionEvent)
 {
     $promise = $actionEvent->getParam(QueryBus::EVENT_PARAM_PROMISE);
     if ($promise instanceof Promise) {
         $newPromise = $promise->then(function ($result) use($actionEvent) {
             if (!$this->authorizationService->isGranted($actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME), $result)) {
                 $actionEvent->stopPropagation(true);
                 throw new UnauthorizedException();
             }
         });
         $actionEvent->setParam(QueryBus::EVENT_PARAM_PROMISE, $newPromise);
     } elseif (!$this->authorizationService->isGranted($actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME))) {
         $actionEvent->stopPropagation(true);
         throw new UnauthorizedException();
     }
 }