Перевод "Getting Started with Zend_Session, _Auth, _Acl. Building an Authorization System in Zend Framework"

Zend, “Getting Started with Zend_Session, _Auth, _Acl. Building an Authorization System in Zend Framework”, public translation into Russian from English More about this translation.

See also 44 similar translations

Translate into another language.

Participants

Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated
1 2 3 4

Getting Started with Zend_Session, _Auth, _Acl. Building an Authorization System in Zend Framework

Introduction to Authorization

After a user has been identified as being authentic, an application can go about its business of providing some useful and desirable resources to a consumer. In many cases, applications might contain different resource types, with some resources having stricter rules regarding access. This process of determining who has access to which resources is the process of "authorization". Authorization in its simplest form is the composition of these elements:

    • the identity whom wishes to be granted access

    • the resource the identity is asking permission to consume

    • and optionally, what the identity is privileged to do with the resource

In Zend Framework, the Zend_Acl component handles the task of building a tree of roles, resources and privileges to manage and query authorization requests against.

Basic Usage of Zend_Acl

When using Zend_Acl, any models can serve as roles or resources by simply implementing the proper interface. To be used in a role capacity, the class must implement the Zend_Acl_Role_Interface, which requires only getRoleId(). To be used in a resource capacity, a class must implement the Zend_Acl_Resource_Interface which similarly requires the class implement the getResourceId() method.

Demonstrated below is a simple user model. This model can take part in our ACL system simply by implementing the Zend_Acl_Role_Interface. The method getRoleId() will return the id "guest" when an ID is not known, or it will return the role ID that was assigned to this actual user object. This value can effectively come from anywhere, a static definition or perhaps dynamically from the users database role itself.

  01. class Default_Model_User implements Zend_Acl_Role_Interface

  02. {

  03.     protected $_aclRoleId = null;

  04.  

  05.     public function getRoleId()

  06.     {

  07.         if ($this->_aclRoleId == null) {

  08.             return 'guest';

Pages: ← previous Ctrl next next untranslated
1 2 3 4