Base for a static organization website

acl.php 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * This is the PHP base ACL configuration file.
  4. *
  5. * Use it to configure access control of your CakePHP application.
  6. *
  7. * @link http://cakephp.org CakePHP(tm) Project
  8. * @package app.Config
  9. * @since CakePHP(tm) v 2.1
  10. */
  11. /**
  12. * Example
  13. * -------
  14. *
  15. * Assumptions:
  16. *
  17. * 1. In your application you created a User model with the following properties:
  18. * username, group_id, password, email, firstname, lastname and so on.
  19. * 2. You configured AuthComponent to authorize actions via
  20. * $this->Auth->authorize = array('Actions' => array('actionPath' => 'controllers/'),...)
  21. *
  22. * Now, when a user (i.e. jeff) authenticates successfully and requests a controller action (i.e. /invoices/delete)
  23. * that is not allowed by default (e.g. via $this->Auth->allow('edit') in the Invoices controller) then AuthComponent
  24. * will ask the configured ACL interface if access is granted. Under the assumptions 1. and 2. this will be
  25. * done via a call to Acl->check() with
  26. *
  27. * array('User' => array('username' => 'jeff', 'group_id' => 4, ...))
  28. *
  29. * as ARO and
  30. *
  31. * '/controllers/invoices/delete'
  32. *
  33. * as ACO.
  34. *
  35. * If the configured map looks like
  36. *
  37. * $config['map'] = array(
  38. * 'User' => 'User/username',
  39. * 'Role' => 'User/group_id',
  40. * );
  41. *
  42. * then PhpAcl will lookup if we defined a role like User/jeff. If that role is not found, PhpAcl will try to
  43. * find a definition for Role/4. If the definition isn't found then a default role (Role/default) will be used to
  44. * check rules for the given ACO. The search can be expanded by defining aliases in the alias configuration.
  45. * E.g. if you want to use a more readable name than Role/4 in your definitions you can define an alias like
  46. *
  47. * $config['alias'] = array(
  48. * 'Role/4' => 'Role/editor',
  49. * );
  50. *
  51. * In the roles configuration you can define roles on the lhs and inherited roles on the rhs:
  52. *
  53. * $config['roles'] = array(
  54. * 'Role/admin' => null,
  55. * 'Role/accountant' => null,
  56. * 'Role/editor' => null,
  57. * 'Role/manager' => 'Role/editor, Role/accountant',
  58. * 'User/jeff' => 'Role/manager',
  59. * );
  60. *
  61. * In this example manager inherits all rules from editor and accountant. Role/admin doesn't inherit from any role.
  62. * Lets define some rules:
  63. *
  64. * $config['rules'] = array(
  65. * 'allow' => array(
  66. * '*' => 'Role/admin',
  67. * 'controllers/users/(dashboard|profile)' => 'Role/default',
  68. * 'controllers/invoices/*' => 'Role/accountant',
  69. * 'controllers/articles/*' => 'Role/editor',
  70. * 'controllers/users/*' => 'Role/manager',
  71. * 'controllers/invoices/delete' => 'Role/manager',
  72. * ),
  73. * 'deny' => array(
  74. * 'controllers/invoices/delete' => 'Role/accountant, User/jeff',
  75. * 'controllers/articles/(delete|publish)' => 'Role/editor',
  76. * ),
  77. * );
  78. *
  79. * Ok, so as jeff inherits from Role/manager he's matched every rule that references User/jeff, Role/manager,
  80. * Role/editor, Role/accountant and Role/default. However, for jeff, rules for User/jeff are more specific than
  81. * rules for Role/manager, rules for Role/manager are more specific than rules for Role/editor and so on.
  82. * This is important when allow and deny rules match for a role. E.g. Role/accountant is allowed
  83. * controllers/invoices/* but at the same time controllers/invoices/delete is denied. But there is a more
  84. * specific rule defined for Role/manager which is allowed controllers/invoices/delete. However, the most specific
  85. * rule denies access to the delete action explicitly for User/jeff, so he'll be denied access to the resource.
  86. *
  87. * If we would remove the role definition for User/jeff, then jeff would be granted access as he would be resolved
  88. * to Role/manager and Role/manager has an allow rule.
  89. */
  90. /**
  91. * The role map defines how to resolve the user record from your application
  92. * to the roles you defined in the roles configuration.
  93. */
  94. $config['map'] = array(
  95. 'User' => 'User/username',
  96. 'Role' => 'User/group_id',
  97. );
  98. /**
  99. * define aliases to map your model information to
  100. * the roles defined in your role configuration.
  101. */
  102. $config['alias'] = array(
  103. 'Role/4' => 'Role/editor',
  104. );
  105. /**
  106. * role configuration
  107. */
  108. $config['roles'] = array(
  109. 'Role/admin' => null,
  110. );
  111. /**
  112. * rule configuration
  113. */
  114. $config['rules'] = array(
  115. 'allow' => array(
  116. '*' => 'Role/admin',
  117. ),
  118. 'deny' => array(),
  119. );