PHP Class CakeDC\Users\Auth\SimpleRbacAuthorize

Matches current plugin/controller/action against defined permissions in permissions.php file
Inheritance: extends Cake\Auth\BaseAuthorize, use trait Cake\Log\LogTrait
Afficher le fichier Open project: CakeDC/users Class Usage Examples

Protected Properties

Свойство Type Description
$_defaultConfig
$_defaultPermissions array Default permissions to be loaded if no provided permissions

Méthodes publiques

Méthode Description
__construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] ) Autoload permission configuration
authorize ( array $user, Cake\Network\Request $request ) : boolean Match the current plugin/controller/action against loaded permissions Set a default role if no role is provided

Méthodes protégées

Méthode Description
_checkPermissions ( array $user, string $role, Cake\Network\Request $request ) : boolean Match against permissions, return if matched Permissions are processed based on the 'permissions' config values
_loadPermissions ( string $key ) : array Load config and retrieve permissions If the configuration file does not exist, or the permissions key not present, return defaultPermissions To be mocked
_matchOrAsterisk ( string | array $possibleValues, string | mixed | null $value, boolean $allowEmpty = false ) : boolean Check if rule matched or '*' present in rule matching anything
_matchPermission ( array $permission, array $user, string $role, Cake\Network\Request $request ) : null | boolean Match the rule for current permission
_startsWith ( string $haystack, string $needle ) : boolean Checks if $heystack begins with $needle

Method Details

__construct() public méthode

Autoload permission configuration
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] )
$registry Cake\Controller\ComponentRegistry component registry
$config array config

_checkPermissions() protected méthode

Match against permissions, return if matched Permissions are processed based on the 'permissions' config values
protected _checkPermissions ( array $user, string $role, Cake\Network\Request $request ) : boolean
$user array current user array
$role string effective role for the current user
$request Cake\Network\Request request
Résultat boolean true if there is a match in permissions

_loadPermissions() protected méthode

Load config and retrieve permissions If the configuration file does not exist, or the permissions key not present, return defaultPermissions To be mocked
protected _loadPermissions ( string $key ) : array
$key string name of the configuration file to read permissions from
Résultat array permissions

_matchOrAsterisk() protected méthode

Check if rule matched or '*' present in rule matching anything
protected _matchOrAsterisk ( string | array $possibleValues, string | mixed | null $value, boolean $allowEmpty = false ) : boolean
$possibleValues string | array Values that are accepted (from permission config)
$value string | mixed | null Value to check with. We'll check the DASHERIZED value too
$allowEmpty boolean If true and $value is null, the rule will pass
Résultat boolean

_matchPermission() protected méthode

Match the rule for current permission
protected _matchPermission ( array $permission, array $user, string $role, Cake\Network\Request $request ) : null | boolean
$permission array The permission configuration
$user array Current user data
$role string Effective user's role
$request Cake\Network\Request Current request
Résultat null | boolean Null if permission is discarded, boolean if a final result is produced

_startsWith() protected méthode

Checks if $heystack begins with $needle
See also: http://stackoverflow.com/a/7168986/2588539
protected _startsWith ( string $haystack, string $needle ) : boolean
$haystack string The whole string
$needle string The beginning to check
Résultat boolean

authorize() public méthode

Match the current plugin/controller/action against loaded permissions Set a default role if no role is provided
public authorize ( array $user, Cake\Network\Request $request ) : boolean
$user array user data
$request Cake\Network\Request request
Résultat boolean

Property Details

$_defaultConfig protected_oe property

protected $_defaultConfig

$_defaultPermissions protected_oe property

Default permissions to be loaded if no provided permissions
protected array $_defaultPermissions
Résultat array