Edgewall Software

Changes between Version 61 and Version 62 of TracFineGrainedPermissions


Ignore:
Timestamp:
Jan 3, 2015, 1:13:46 PM (9 years ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracFineGrainedPermissions

    v61 v62  
    33[[TracGuideToc]]
    44
    5 There's a general mechanism in place that allows custom **permission policy plugins** to grant or deny any action on any kind of Trac resources, even at the level of specific versions of such resources.
    6 
    7 That mechanism is `authz_policy`, which is an optional module (in `tracopt.perm.authz_policy.*`), so it's installed by default and can simply be activated via the //Plugins// panel in the Trac administration module.
    8 
     5There is a general mechanism in place that allows custom **permission policy plugins** to grant or deny any action on any kind of Trac resource, even at the level of specific versions of such resources.
     6
     7That mechanism is `authz_policy`, which is an optional module in `tracopt.perm.authz_policy.*`, so it is installed by default. It can be activated via the //Plugins// panel in the Trac administration module.
    98
    109== Permission Policies ==
    1110
    12 A great diversity of permission policies can be implemented, and Trac comes with a few examples.
     11A great diversity of permission policies can be implemented and Trac comes with a few examples.
    1312
    1413Which policies are currently active is determined by a configuration setting in TracIni:
    15 e.g.
     14
    1615{{{#!ini
    1716[trac]
     
    2019This lists the [#AuthzSourcePolicy] described below as the first policy, followed by the !DefaultPermissionPolicy which checks for the traditional coarse grained style permissions described in TracPermissions, and the !LegacyAttachmentPolicy which knows how to use the coarse grained permissions for checking the permissions available on attachments.
    2120
    22 Among the possible optional choices, there is [#AuthzPolicy], a very generic permission policy, based on an Authz-style system. See
     21Among the optional choices, there is [#AuthzPolicy], a very generic permission policy, based on an Authz-style system. See
    2322[trac:source:branches/1.0-stable/tracopt/perm/authz_policy.py authz_policy.py] for details.
    2423
     
    2625
    2726See also [trac:source:branches/1.0-stable/sample-plugins/permissions sample-plugins/permissions] for more examples.
    28 
    2927
    3028=== !AuthzPolicy ===
     
    3331* Put a [http://swapoff.org/files/authzpolicy.conf authzpolicy.conf] file somewhere, preferably on a secured location on the server, not readable for others than the webuser. If the  file contains non-ASCII characters, the UTF-8 encoding should be used.
    3432* Update your `trac.ini`:
    35   1. modify the [TracIni#trac-section permission_policies] entry in the `[trac]` section
     33  1. modify the [TracIni#trac-section permission_policies] entry in the `[trac]` section:
    3634{{{#!ini
    3735[trac]
     
    3937permission_policies = AuthzPolicy, DefaultPermissionPolicy, LegacyAttachmentPolicy
    4038}}}
    41   1. add a new `[authz_policy]` section
     39  1. add a new `[authz_policy]` section:
    4240{{{#!ini
    4341[authz_policy]
    4442authz_file = /some/trac/env/conf/authzpolicy.conf
    4543}}}
    46   1. enable the plugin through [/admin/general/plugin WebAdmin] or by editing the `[components]` section
     44  1. enable the plugin through [/admin/general/plugin WebAdmin] or by editing the `[components]` section:
    4745{{{#!ini
    4846[components]
     
    5048}}}
    5149
    52 
    5350==== Usage Notes ====
    54 Note that the order in which permission policies are specified is quite critical,
    55 as policies will be examined in the sequence provided.
     51
     52Note the order in which permission policies are specified: policies are implemented in the sequence provided and therefore may override earlier policy specifications.
    5653
    5754A policy will return either `True`, `False` or `None` for a given permission check. `True` is returned if the policy explicitly grants the permission. `False` is returned if the policy explicitly denies the permission. `None` is returned if the policy is unable to either grant or deny the permission.
    5855
    59 NOTE: Only if the return value is `None` will the ''next'' permission policy be consulted.
    60 If none of the policies explicitly grants the permission, the final result will be `False`
    61 (i.e. permission denied).
     56NOTE: Only if the return value is `None` will the ''next'' permission policy be consulted. If none of the policies explicitly grants the permission, the final result will be `False`, i.e. permission denied.
    6257
    6358The `authzpolicy.conf` file is a `.ini` style configuration file:
     
    6863* =
    6964}}}
    70 * Each section of the config is a glob pattern used to match against a Trac resource
    71   descriptor. These descriptors are in the form:
     65* Each section of the config is a glob pattern used to match against a Trac resource descriptor. These descriptors are in the form:
    7266{{{
    7367<realm>:<id>@<version>[/<realm>:<id>@<version> ...]
    7468}}}
    75   Resources are ordered left to right, from parent to child. If any
    76   component is inapplicable, `*` is substituted. If the version pattern is
    77   not specified explicitely, all versions (`@*`) is added implicitly
    78 
    79   Example: Match the WikiStart page
     69
     70Resources are ordered left to right, from parent to child. If any component is inapplicable, `*` is substituted. If the version pattern is not specified explicitly, all versions (`@*`) is added implicitly. Example: Match the WikiStart page:
    8071{{{#!ini
    8172[wiki:*]
     
    8576}}}
    8677
    87   Example: Match the attachment `wiki:WikiStart@117/attachment:FOO.JPG@*`
    88   on WikiStart
     78Example: Match the attachment `wiki:WikiStart@117/attachment:FOO.JPG@*` on WikiStart:
    8979{{{#!ini
    9080[wiki:*]
     
    9585}}}
    9686
    97 * Sections are checked against the current Trac resource descriptor '''IN ORDER''' of
    98   appearance in the configuration file. '''ORDER IS CRITICAL'''.
    99 
    100 * Once a section matches, the current username is matched against the keys
    101   (usernames) of the section, '''IN ORDER'''.
     87* Sections are checked against the current Trac resource descriptor '''IN ORDER''' of appearance in the configuration file. '''ORDER IS CRITICAL'''.
     88
     89* Once a section matches, the current username is matched against the keys (usernames) of the section, '''IN ORDER'''.
    10290  * If a key (username) is prefixed with a `@`, it is treated as a group.
    103   * If a value (permission) is prefixed with a `!`, the permission is
    104     denied rather than granted.
    105 
    106   The username will match any of 'anonymous', 'authenticated', <username> or '*', using normal Trac permission rules. || '''Note:''' Other groups which are created by user (e.g. by 'adding subjects to groups' on web interface page //Admin / Permissions//) cannot be used. See [trac:ticket:5648 #5648] for details about this missing feature ||
     91  * If a value (permission) is prefixed with a `!`, the permission is denied rather than granted.
     92
     93The username will match any of 'anonymous', 'authenticated', <username> or '*', using normal Trac permission rules. || '''Note:''' Other groups which are created by user (e.g. by 'adding subjects to groups' on web interface page //Admin / Permissions//) cannot be used. See [trac:ticket:5648 #5648] for details about this missing feature. ||
    10794
    10895For example, if the `authz_file` contains:
     
    123110
    124111Then:
    125   * All versions of WikiStart will be viewable by everybody (including anonymous)
     112  * All versions of WikiStart will be viewable by everybody, including anonymous
    126113  * !PrivatePage will be viewable only by john
    127114  * other pages will be viewable only by john and jack
     
    166153}}}
    167154
    168 Very fine grain repository access:
     155Very granular repository access:
    169156{{{#!ini
    170157# John has BROWSER_VIEW and FILE_VIEW access to trunk/src/some/location/ only
     
    172159john = BROWSER_VIEW, FILE_VIEW
    173160
    174 
    175161# John has BROWSER_VIEW and FILE_VIEW access to only revision 1 of all files at trunk/src/some/location only
    176162[repository:test_repo@*/source:trunk/src/some/location/*@1]
    177163john = BROWSER_VIEW, FILE_VIEW
    178164
    179 
    180165# John has BROWSER_VIEW and FILE_VIEW access to all revisions of 'somefile' at trunk/src/some/location only
    181166[repository:test_repo@*/source:trunk/src/some/location/somefile@*]
    182167john = BROWSER_VIEW, FILE_VIEW
    183168
    184 
    185169# John has BROWSER_VIEW and FILE_VIEW access to only revision 1 of 'somefile' at trunk/src/some/location only
    186170[repository:test_repo@*/source:trunk/src/some/location/somefile@1]
     
    190174Note: In order for Timeline to work/visible for John, we must add CHANGESET_VIEW to the above permission list.
    191175
    192 
    193176==== Missing Features ====
    194 Although possible with the !DefaultPermissionPolicy handling (see Admin panel), fine-grained permissions still miss those grouping features (see [trac:ticket:9573 #9573], [trac:ticket:5648 #5648]). Patches are partially available, see forgotten authz_policy.2.patch  part of [trac:ticket:6680 #6680]).
     177Although possible with the !DefaultPermissionPolicy handling (see Admin panel), fine-grained permissions still miss those grouping features (see [trac:ticket:9573 #9573], [trac:ticket:5648 #5648]). Patches are partially available, see authz_policy.2.patch, part of [trac:ticket:6680 #6680].
    195178
    196179You cannot do the following:
     
    203186}}}
    204187
    205 Permission groups are not supported either. You cannot do the following:
     188Permission groups are not supported either, so you cannot do the following:
    206189{{{#!ini
    207190[groups]
     
    216199=== !AuthzSourcePolicy  (mod_authz_svn-like permission policy) === #AuthzSourcePolicy
    217200
    218 At the time of this writing, the old fine grained permissions system from Trac 0.11 and before used for restricting access to the repository has  been converted to a permission policy component, but from the user point of view, this makes little if no difference.
    219 
    220 That kind of fine-grained permission control needs a definition file, which is the one used by Subversion's mod_authz_svn.
    221 More information about this file format and about its usage in Subversion is available in the  [http://svnbook.red-bean.com/en/1.5/svn.serverconfig.pathbasedauthz.html Path-Based Authorization] section in the Server Configuration chapter of the svn book.
     201At the time of this writing, the old granular permissions system from Trac 0.11 and before used for restricting access to the repository has been converted to a permission policy component. But from the user's point of view, this makes little if any difference.
     202
     203That kind of granular permission control needs a definition file, which is the one used by Subversion's mod_authz_svn.
     204More information about this file format and about its usage in Subversion is available in the [http://svnbook.red-bean.com/en/1.5/svn.serverconfig.pathbasedauthz.html Path-Based Authorization] section in the Server Configuration chapter of the svn book.
    222205
    223206Example:
     
    240223==== Trac Configuration ====
    241224
    242 To activate fine grained permissions you __must__ specify the {{{authz_file}}} option in the {{{[trac]}}} section of trac.ini. If this option is set to null or not specified the permissions will not be used.
     225To activate granular permissions you __must__ specify the {{{authz_file}}} option in the {{{[trac]}}} section of trac.ini. If this option is set to null or not specified, the permissions will not be used.
    243226
    244227{{{#!ini
     
    247230}}}
    248231
    249 If you want to support the use of the `[`''modulename''`:/`''some''`/`''path''`]` syntax within the `authz_file`, add 
     232If you want to support the use of the `[`''modulename''`:/`''some''`/`''path''`]` syntax within the `authz_file`, add:
    250233
    251234{{{#!ini
     
    253236}}}
    254237
    255 where ''modulename'' refers to the same repository indicated by the `repository_dir` entry in the `[trac]` section. As an example, if the `repository_dir` entry in the `[trac]` section is {{{/srv/active/svn/blahblah}}}, that would yield the following:
     238where ''modulename'' refers to the same repository indicated by the `repository_dir` entry in the `[trac]` section. As an example, if the `repository_dir` entry in the `[trac]` section is {{{/srv/active/svn/somemodule}}}, that would yield the following:
    256239
    257240{{{ #!ini
    258241[trac]
    259242authz_file = /path/to/svnaccessfile
    260 authz_module_name = blahblah
     243authz_module_name = somemodule
    261244...
    262 repository_dir = /srv/active/svn/blahblah
    263 }}}
    264 
    265 where the svn access file, {{{/path/to/svnaccessfile}}}, contains entries such as {{{[blahblah:/some/path]}}}.
     245repository_dir = /srv/active/svn/somemodule
     246}}}
     247
     248where the svn access file, {{{/path/to/svnaccessfile}}}, contains entries such as {{{[somemodule:/some/path]}}}.
    266249
    267250'''Note:''' Usernames inside the Authz file __must__ be the same as those used inside trac.
     
    287270}}}
    288271
    289 For information about how to restrict access to entire projects in a multiple project environment see [trac:wiki:TracMultipleProjectsSVNAccess]
     272For information about how to restrict access to entire projects in a multiple project environment see [trac:wiki:TracMultipleProjectsSVNAccess].
    290273
    291274== Debugging permissions
     
    298281}}}
    299282
    300 And watch:
     283Display the trac.log to understand what checks are being performed:
    301284{{{#!sh
    302285tail -n 0 -f log/trac.log | egrep '\[perm\]|\[authz_policy\]'
    303286}}}
    304287
    305 to understand what checks are being performed. See the sourced documentation of the plugin for more info.
    306 
     288See the sourced documentation of the plugin for more info.
    307289
    308290----