You are here

README.txt in Secure Permissions 7.2

Same filename and directory in other branches
  1. 6 README.txt
  2. 7 README.txt

README file for Secure Permissions.

File

README.txt
View source
  1. /**
  2. * @file
  3. * README file for Secure Permissions.
  4. */
  5. Secure Permissions
  6. Disables the user interface for creating and assigning roles and permissions.
  7. CONTENTS
  8. --------
  9. 1. Use case
  10. 2. Installation
  11. 3. Exporting settings to code
  12. 4. Configuring the module
  13. 5. API Hooks
  14. 5.1 hook_secure_permissions_roles()
  15. 5.2 hook_secure_permissions($role)
  16. 6. To Do
  17. Secure Permissions is an advanced security module for Drupal 7. Please
  18. read this document before continuing.
  19. This module was inspired by some claims regarding superior security of the
  20. Plone platform. See, in particular, 'Problem A2: Broken Access Control' at
  21. http://plone.org/products/plone/security/overview/security-overview-of-plone
  22. The module was inspired by @djay75 via Twitter.
  23. ----
  24. 1. Use case
  25. This module is designed for cases where you want control of Roles and
  26. Permissions only in a development environment. When fully enabled, this module
  27. will make it so that the live site cannot have its permissions modified, except
  28. through code.
  29. It may be sufficient for most users to simply enable this module on the live
  30. site, and to disable it when it is no longer needed.
  31. ----
  32. 2. Installation
  33. Before installing this module you should configure the site Roles and
  34. Permissions as you see fit. After installing and configuring this module,
  35. changes to these settings can only be made through code.
  36. On installation this module will have two immediate effects:
  37. 1. Permissions will no longer be editable through the user interface.
  38. 2. Roles will no longer be editable through the user interface.
  39. On many sites, this is sufficient. However, for advanced security, you
  40. have several additonal options. See sections 3 and 4 for details.
  41. The module will also add a permission to your site, 'Export permission
  42. definitions'. This permission should be given to trusted roles before you
  43. continue.
  44. Users with this permissions may configure this module and may export site
  45. Roles and Permissions to code.
  46. ----
  47. 3. Exporting settings to code
  48. Give your account the 'Export permission definitions' permission defined by the
  49. module or log in as the Site Maintenance user.
  50. Find the link under People and Permissions >> Secure Permissions
  51. Click the Export Permissions tab. It should take you to a form with two text
  52. areas, filled with PHP code.
  53. The Secure permissions module stores the permissions in a module (file) that is
  54. inaccessible through the user interface.
  55. You now need to create and enable that module in 4 easy steps.
  56. 1. Create directory. cd to /sites/all/modules and issue the command:
  57. mkdir secure_permissions_data
  58. 2. Create 2 empty files. cd to /sites/all/modules/secure_permissions_data and
  59. issue the command: touch secure_permissions_data.info secure_permissions_data.module
  60. 3. Copy data. Copy the text from the fields below into the respective files you just
  61. created using the tools of your choice.
  62. 4. Enable the module. Navigate to admin/build/modules/list and enable your new module.
  63. To change permissions with the module enabled, you must now edit your
  64. secure_permissions_data.module file.
  65. Now you are ready to configure the Secure Permissions module to run.
  66. After editing the file navigate to /admin/user/secure_permissions/view, select
  67. 'Load permissions from code'and click 'Save configuration' to update the permissions.
  68. You may rename the module; remember to rename all the functions.
  69. Note that if you have set an administrative role, the permissions for that role will not
  70. be exported.
  71. ----
  72. 4. Configuring the module
  73. For advanced features of this module, you must export your Roles and Permissions
  74. to code. Since this cannot be done before the module is installed, the module
  75. will not enforce its rules until you tell it to do so.
  76. To activate the module, navigate to:
  77. Administer > Configuration and Modules > People and Permissions > Secure
  78. Permissions
  79. Here, you can tell the Secure Permissions module how to behave. You have eight
  80. options that can be set. These are split into two groups, those that control the
  81. User Interface of Drupal, and those that affect how permissions are loaded from
  82. code via the API.
  83. USER INTERFACE SETTINGS
  84. 'Disable permissions and roles forms'
  85. Check to make the Roles and Permissions forms unchangeable. Users may
  86. be able to view them, but cannot edit or submit them. Default is OFF.
  87. You should enable this setting after granting your account the ability to
  88. access 'Export permission definitions'.
  89. 'Show permissions page'
  90. Check to allow the Permissions page to be viewed by administrators.
  91. Disabling this option will prevent users from seeing permission definitions
  92. at all. Default is ON.
  93. 'Show roles page'
  94. Check to allow the Roles page to be viewed by administrators.
  95. Disabling this option will prevent users from seeing role definitions
  96. at all. Default is ON.
  97. 'Display permissions updates'
  98. Check to display messages when Secure Permissions reset site permissions.
  99. Default is ON.
  100. API SETTINGS
  101. 'Load permissions from code'
  102. Check to activate the module's advanced features.
  103. When set, the module will rebuild Roles and Permissions every time that
  104. a module is enabled or disabled. Checking this option means that all
  105. site Roles and Permissions will be managed in code. Default is OFF.
  106. NOTE: none of the following settings will be in effect if 'Load permissions
  107. from code' is not enabled. Using these features is not required, however.
  108. 'Reload default permissions on rebuild'
  109. Check to have the module load Drupal's default permissions for the anonymous
  110. and authenticated user roles when permissions are rebuilt. Default is OFF.
  111. 'Use administrative role'
  112. Check to include an administrative role from the site.
  113. The 'administrator' role ships with Drupal, and has all site permissions. If
  114. you uncheck this option, this role will be deleted. Default is ON.
  115. 'Administrative role name'
  116. Set to the name of the administrative role you wish to use.
  117. If 'Use administrative role' is disabled, this value is not used.
  118. Default is 'administrator'. Normally, you should not change this value.
  119. NOTE: If using translations, this string should not be translated through
  120. this setting.
  121. ----
  122. 5. API hooks
  123. The module functions by using two API hooks, described below. To use these
  124. functions you must place them in a custom module file and name them properly.
  125. The export function will generate these hooks for you. The API is described
  126. here for developers.
  127. ----
  128. 5.1 hook_secure_permissions_roles()
  129. Defines the roles used by a site. These are keyed by the uniqueness of the role
  130. name, since we cannot guarantee the role id used by various sites.
  131. WARNING: If you do not implement this hook, the module will reset your site
  132. roles to the roles that ship with Drupal's default install.
  133. Note that the module implements this hook to ensure that the 'anonymous user'
  134. and 'authenticated user' roles always exist.
  135. If the 'Use administrative role' is set to TRUE, the module will also maintain
  136. an administrative role that has all site permissions.
  137. The hook returns a simple positional array of unique role names.
  138. function example_secure_permissions_roles() {
  139. return array(
  140. 'editor',
  141. 'producer',
  142. );
  143. }
  144. ----
  145. 5.2 hook_secure_permissions($role)
  146. Defines the permissions assigned to each role. Typically, you will implement
  147. all permissions for your site in this hook.
  148. This hook takes a $role string as an argument. You should respond with the
  149. appropriate permissions grants for that role. You should only return grants
  150. that are TRUE.
  151. function example_secure_permissions($role) {
  152. $permissions = array(
  153. 'anonymous user' => array(
  154. 'access content',
  155. 'use text format 1',
  156. ),
  157. 'authenticated user' => array(
  158. 'access comments',
  159. 'access content',
  160. 'post comments',
  161. 'post comments without approval',
  162. 'use text format 1',
  163. ),
  164. 'editor' => array(
  165. 'bypass node access',
  166. 'administer nodes',
  167. ),
  168. 'producer' => array(
  169. 'create page content',
  170. 'edit any page content',
  171. ),
  172. );
  173. if (isset($permissions[$role])) {
  174. return $permissions[$role];
  175. }
  176. }
  177. NOTE: The use of isset() is recommended here, since the hook will fire
  178. once per role, and it is possible that your module will not reply in all cases.
  179. NOTE: If configured to do so, the module will return the default permissions
  180. defined by Drupal's installer. Disable the 'Reload default permissions on
  181. rebuild' setting to disable this behavior.