SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

isActionAllowed #

Specifies if an action is allowed, denied or conditional based on the rights provided as the first argument:

  • allowed is returned when an action is authorized without condition
  • conditional is returned when the authorization depends on a closure
  • denied is returned when the action is forbidden

An action is defined as a pair of action and controller (mandatory), plus an index and a collection(optional).

You can get the rights from Kuzzle by using Security.getUserRights and Kuzzle.getMyRights.


isActionAllowed(rights, controller, action, index, collection) #

ArgumentsTypeDescription
rightsJSON arrayRights list
controllerStringThe controller
actionStringThe action
indexStringThe index
collectionStringThe collection

Return Value #

Returns either allowed, denied or conditional.

Usage #

<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Security;
$kuzzle = new Kuzzle('localhost');
try {
  $rights = $kuzzle->security()->getMyRights();
  switch ($kuzzle->security()->isActionAllowed($rights, 'read', 'get', 'index1', 'collection1')) {
    case Security::ACTION_ALLOWED:
      // code...
      break;
    case Security::ACTION_DENIED:
      // code...
      break;
    case Security::ACTION_CONDITIONAL:
      // code...
      break;
  }
}
catch (ErrorException $e) {
}