PHP Класс Nette\Security\Permission

This solution is mostly based on Zend_Acl (c) Zend Technologies USA Inc. (http://www.zend.com), new BSD license
Автор: David Grudl
Наследование: extends Nette\Object, implements Nette\Security\IAuthorizator
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
addResource ( $resource, $parent = NULL ) : self Adds a Resource having an identifier unique to the list.
addRole ( $role, $parents = NULL ) : self Adds a Role to the list. The most recently added parent takes precedence over parents that were previously added.
allow ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL ) : self Allows one or more Roles access to [certain $privileges upon] the specified Resource(s).
deny ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL ) : self Denies one or more Roles access to [certain $privileges upon] the specified Resource(s).
getQueriedResource ( ) : mixed Returns real currently queried Resource. Use by assertion.
getQueriedRole ( ) : mixed Returns real currently queried Role. Use by assertion.
getResources ( ) : array Returns all Resources.
getRoleParents ( $role ) : array Returns existing Role's parents ordered by ascending priority.
getRoles ( ) : array Returns all Roles.
hasResource ( $resource ) : boolean Returns TRUE if the Resource exists in the list.
hasRole ( $role ) : boolean Returns TRUE if the Role exists in the list.
isAllowed ( $role = self::ALL, $resource = self::ALL, $privilege = self::ALL ) : boolean Returns TRUE if and only if the Role has access to [certain $privileges upon] the Resource.
removeAllResources ( ) : self Removes all Resources.
removeAllRoles ( ) : self Removes all Roles from the list.
removeAllow ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL ) : self Removes "allow" permissions from the list in the context of the given Roles, Resources, and privileges.
removeDeny ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL ) : self Removes "deny" restrictions from the list in the context of the given Roles, Resources, and privileges.
removeResource ( $resource ) : self Removes a Resource and all of its children.
removeRole ( $role ) : self Removes the Role from the list.
resourceInheritsFrom ( $resource, $inherit, $onlyParent = FALSE ) : boolean Returns TRUE if $resource inherits from $inherit. If $onlyParents is TRUE, then $resource must inherit directly from $inherit.
roleInheritsFrom ( $role, $inherit, $onlyParents = FALSE ) : boolean Returns TRUE if $role inherits from $inherit. If $onlyParents is TRUE, then $role must inherit directly from $inherit.

Защищенные методы

Метод Описание
setRule ( $toAdd, $type, $roles, $resources, $privileges, $assertion = NULL ) : self Performs operations on Access Control List rules.

Приватные методы

Метод Описание
checkResource ( $resource, $need = TRUE ) : void Checks whether Resource is valid and exists in the list.
checkRole ( $role, $need = TRUE ) : void Checks whether Role is valid and exists in the list.
getRuleType ( $resource, $role, $privilege ) : mixed Returns the rule type associated with the specified Resource, Role, and privilege.
getRules ( $resource, $role, $create = FALSE ) : array | null Returns the rules associated with a Resource and a Role, or NULL if no such rules exist.
searchRolePrivileges ( $all, $role, $resource, $privilege ) : mixed Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule allowing/denying $role access to a/all $privilege upon $resource.

Описание методов

addResource() публичный Метод

Adds a Resource having an identifier unique to the list.
public addResource ( $resource, $parent = NULL ) : self
Результат self

addRole() публичный Метод

Adds a Role to the list. The most recently added parent takes precedence over parents that were previously added.
public addRole ( $role, $parents = NULL ) : self
Результат self

allow() публичный Метод

If $assertion is provided, then it must return TRUE in order for rule to apply.
public allow ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL ) : self
Результат self

deny() публичный Метод

If $assertion is provided, then it must return TRUE in order for rule to apply.
public deny ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL ) : self
Результат self

getQueriedResource() публичный Метод

Returns real currently queried Resource. Use by assertion.
public getQueriedResource ( ) : mixed
Результат mixed

getQueriedRole() публичный Метод

Returns real currently queried Role. Use by assertion.
public getQueriedRole ( ) : mixed
Результат mixed

getResources() публичный Метод

Returns all Resources.
public getResources ( ) : array
Результат array

getRoleParents() публичный Метод

Returns existing Role's parents ordered by ascending priority.
public getRoleParents ( $role ) : array
Результат array

getRoles() публичный Метод

Returns all Roles.
public getRoles ( ) : array
Результат array

hasResource() публичный Метод

Returns TRUE if the Resource exists in the list.
public hasResource ( $resource ) : boolean
Результат boolean

hasRole() публичный Метод

Returns TRUE if the Role exists in the list.
public hasRole ( $role ) : boolean
Результат boolean

isAllowed() публичный Метод

This method checks Role inheritance using a depth-first traversal of the Role list. The highest priority parent (i.e., the parent most recently added) is checked first, and its respective parents are checked similarly before the lower-priority parents of the Role are checked.
public isAllowed ( $role = self::ALL, $resource = self::ALL, $privilege = self::ALL ) : boolean
Результат boolean

removeAllResources() публичный Метод

Removes all Resources.
public removeAllResources ( ) : self
Результат self

removeAllRoles() публичный Метод

Removes all Roles from the list.
public removeAllRoles ( ) : self
Результат self

removeAllow() публичный Метод

Removes "allow" permissions from the list in the context of the given Roles, Resources, and privileges.
public removeAllow ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL ) : self
Результат self

removeDeny() публичный Метод

Removes "deny" restrictions from the list in the context of the given Roles, Resources, and privileges.
public removeDeny ( $roles = self::ALL, $resources = self::ALL, $privileges = self::ALL ) : self
Результат self

removeResource() публичный Метод

Removes a Resource and all of its children.
public removeResource ( $resource ) : self
Результат self

removeRole() публичный Метод

Removes the Role from the list.
public removeRole ( $role ) : self
Результат self

resourceInheritsFrom() публичный Метод

Returns TRUE if $resource inherits from $inherit. If $onlyParents is TRUE, then $resource must inherit directly from $inherit.
public resourceInheritsFrom ( $resource, $inherit, $onlyParent = FALSE ) : boolean
Результат boolean

roleInheritsFrom() публичный Метод

Returns TRUE if $role inherits from $inherit. If $onlyParents is TRUE, then $role must inherit directly from $inherit.
public roleInheritsFrom ( $role, $inherit, $onlyParents = FALSE ) : boolean
Результат boolean

setRule() защищенный Метод

Performs operations on Access Control List rules.
protected setRule ( $toAdd, $type, $roles, $resources, $privileges, $assertion = NULL ) : self
Результат self