protected function setRsa($service, $component = null, $verbs = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], $requestor = ServiceRequestorTypes::API)
 {
     $verbMask = VerbsMask::arrayToMask($verbs);
     $rsa = ['service' => $service, 'component' => $component, 'verb_mask' => $verbMask, 'requestor_mask' => $requestor];
     $this->rsa[] = $rsa;
     Session::put($this->rsaKey, $this->rsa);
 }
Exemple #2
0
 /**
  * @param string $action
  * @param string $service
  * @param string $component
  *
  * @returns bool
  */
 public static function getServiceFilters($action, $service, $component = null)
 {
     if (static::isSysAdmin()) {
         return [];
     }
     $services = ArrayUtils::clean(static::get('role.services'));
     $serviceAllowed = null;
     $serviceFound = false;
     $componentFound = false;
     $action = VerbsMask::toNumeric(static::cleanAction($action));
     foreach ($services as $svcInfo) {
         $tempService = ArrayUtils::get($svcInfo, 'service');
         if (null === ($tempVerbs = ArrayUtils::get($svcInfo, 'verb_mask'))) {
             //  Check for old verbs array
             if (null !== ($temp = ArrayUtils::get($svcInfo, 'verbs'))) {
                 $tempVerbs = VerbsMask::arrayToMask($temp);
             }
         }
         if (0 == strcasecmp($service, $tempService)) {
             $serviceFound = true;
             $tempComponent = ArrayUtils::get($svcInfo, 'component');
             if (!empty($component)) {
                 if (0 == strcasecmp($component, $tempComponent)) {
                     $componentFound = true;
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         return ['filters' => $filters, 'filter_op' => $operator];
                     }
                 } elseif (empty($tempComponent) || '*' == $tempComponent) {
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         $serviceAllowed = ['filters' => $filters, 'filter_op' => $operator];
                     }
                 }
             } else {
                 if (empty($tempComponent) || '*' == $tempComponent) {
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         $serviceAllowed = ['filters' => $filters, 'filter_op' => $operator];
                     }
                 }
             }
         }
     }
     if ($componentFound) {
         // at least one service and component match was found, but not the right verb
         return null;
     } elseif ($serviceFound) {
         return $serviceAllowed;
     }
     return null;
 }