forked from phalcon/cphalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl.c
79 lines (72 loc) · 3.01 KB
/
acl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
+------------------------------------------------------------------------+
*/
#include "acl.h"
#include "kernel/main.h"
/**
* Phalcon\Acl
*
* This component allows to manage ACL lists. An access control list (ACL) is a list
* of permissions attached to an object. An ACL specifies which users or system processes
* are granted access to objects, as well as what operations are allowed on given objects.
*
*<code>
*
* $acl = new Phalcon\Acl\Adapter\Memory();
*
* //Default action is deny access
* $acl->setDefaultAction(Phalcon\Acl::DENY);
*
* //Create some roles
* $roleAdmins = new Phalcon\Acl\Role('Administrators', 'Super-User role');
* $roleGuests = new Phalcon\Acl\Role('Guests');
*
* //Add "Guests" role to acl
* $acl->addRole($roleGuests);
*
* //Add "Designers" role to acl
* $acl->addRole('Designers');
*
* //Define the "Customers" resource
* $customersResource = new Phalcon\Acl\Resource('Customers', 'Customers management');
*
* //Add "customers" resource with a couple of operations
* $acl->addResource($customersResource, 'search');
* $acl->addResource($customersResource, array('create', 'update'));
*
* //Set access level for roles into resources
* $acl->allow('Guests', 'Customers', 'search');
* $acl->allow('Guests', 'Customers', 'create');
* $acl->deny('Guests', 'Customers', 'update');
*
* //Check whether role has access to the operations
* $acl->isAllowed('Guests', 'Customers', 'edit'); //Returns 0
* $acl->isAllowed('Guests', 'Customers', 'search'); //Returns 1
* $acl->isAllowed('Guests', 'Customers', 'create'); //Returns 1
*
*</code>
*/
zend_class_entry *phalcon_acl_ce;
/**
* Phalcon\Acl initializer
*/
PHALCON_INIT_CLASS(Phalcon_Acl){
PHALCON_REGISTER_CLASS(Phalcon, Acl, acl, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
zend_declare_class_constant_long(phalcon_acl_ce, SL("ALLOW"), PHALCON_ACL_ALLOW TSRMLS_CC);
zend_declare_class_constant_long(phalcon_acl_ce, SL("DENY"), PHALCON_ACL_DENY TSRMLS_CC);
return SUCCESS;
}