Edgewall Software

Changes between Version 2 and Version 3 of 1.1/TracFineGrainedPermissions


Ignore:
Timestamp:
Jan 10, 2015, 10:17:19 AM (9 years ago)
Author:
Jun Omae
Comment:

Merged TracFineGrainedPermissions@55-61

Legend:

Unmodified
Added
Removed
Modified
  • 1.1/TracFineGrainedPermissions

    v2 v3  
     1= Fine grained permissions =
    12[[PageOutline(2-5, Contents, floated)]]
    2 = Fine grained permissions =
    3 
    4 Before Trac 0.11, it was only possible to define fine-grained permissions checks on the repository browser sub-system.
    5 
    6 Since 0.11, 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.
    7 
    8 Note that for Trac 0.12, `authz_policy` has been integrated as 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.
     3[[TracGuideToc]]
     4
     5There'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
     7That 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.
    98
    109
     
    1514Which policies are currently active is determined by a configuration setting in TracIni:
    1615e.g.
    17 {{{
     16{{{#!ini
    1817[trac]
    1918permission_policies = ReadonlyWikiPolicy, DefaultPermissionPolicy, LegacyAttachmentPolicy
     
    2221
    2322Among the possible optional choices, there is [#AuthzPolicy], a very generic permission policy, based on an Authz-style system. See
    24 [trac:source:branches/0.12-stable/tracopt/perm/authz_policy.py authz_policy.py] for details.
     23[trac:source:branches/1.0-stable/tracopt/perm/authz_policy.py authz_policy.py] for details.
    2524
    2625Another popular permission policy [#AuthzSourcePolicy], re-implements the pre-0.12 support for checking fine-grained permissions limited to Subversion repositories in terms of the new system.
    2726
    28 See also [trac:source:branches/0.12-stable/sample-plugins/permissions sample-plugins/permissions] for more examples.
     27See also [trac:source:branches/1.0-stable/sample-plugins/permissions sample-plugins/permissions] for more examples.
    2928
    3029
    3130=== !AuthzPolicy ===
    3231==== Configuration ====
    33 * Install [http://www.voidspace.org.uk/python/configobj.html ConfigObj] (still needed for 0.12 and later).
    34 * Copy [browser:/trunk/tracopt/perm/authz_policy.py /tracopt/perm/authz_policy.py] to your environment's plugins directory (only for Trac 0.11).
     32* Install [http://www.voidspace.org.uk/python/configobj.html ConfigObj].
    3533* 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.
    3634* Update your `trac.ini`:
    3735  1. modify the [TracIni#trac-section permission_policies] entry in the `[trac]` section
    38 {{{
     36{{{#!ini
    3937[trac]
    4038...
     
    4240}}}
    4341  1. add a new `[authz_policy]` section
    44 {{{
     42{{{#!ini
    4543[authz_policy]
    4644authz_file = /some/trac/env/conf/authzpolicy.conf
    4745}}}
    4846  1. enable the plugin through [/admin/general/plugin WebAdmin] or by editing the `[components]` section
    49 {{{
     47{{{#!ini
    5048[components]
    51 ...
    52 # Trac 0.12
    5349tracopt.perm.authz_policy.* = enabled
    54 # for Trac 0.11 use this
    55 #authz_policy.* = enabled
    5650}}}
    5751
     
    6862
    6963The `authzpolicy.conf` file is a `.ini` style configuration file:
    70 {{{
     64{{{#!ini
    7165[wiki:PrivatePage@*]
    7266john = WIKI_VIEW, !WIKI_MODIFY
     
    8478
    8579  Example: Match the WikiStart page
    86 {{{
     80{{{#!ini
    8781[wiki:*]
    8882[wiki:WikiStart*]
     
    9387  Example: Match the attachment `wiki:WikiStart@117/attachment:FOO.JPG@*`
    9488  on WikiStart
    95 {{{
     89{{{#!ini
    9690[wiki:*]
    9791[wiki:WikiStart*]
     
    113107
    114108For example, if the `authz_file` contains:
    115 {{{
     109{{{#!ini
    116110[wiki:WikiStart@*]
    117111* = WIKI_VIEW
     
    134128
    135129Groups:
    136 {{{
     130{{{#!ini
    137131[groups]
    138132admins = john, jack
     
    155149
    156150Some repository examples (Browse Source specific):
    157 {{{
     151{{{#!ini
    158152# A single repository:
    159153[repository:test_repo@*]
     
    173167
    174168Very fine grain repository access:
    175 {{{
     169{{{#!ini
    176170# John has BROWSER_VIEW and FILE_VIEW access to trunk/src/some/location/ only
    177171[repository:test_repo@*/source:trunk/src/some/location/*@*]
     
    201195
    202196You cannot do the following:
    203 {{{
     197{{{#!ini
    204198[groups]
    205199team1 = a, b, c
     
    210204
    211205Permission groups are not supported either. You cannot do the following:
    212 {{{
     206{{{#!ini
    213207[groups]
    214208permission_level_1 = WIKI_VIEW, TICKET_VIEW
     
    228222
    229223Example:
    230 {{{
     224{{{#!ini
    231225[/]
    232226* = r
     
    248242To 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.
    249243
    250 {{{
     244{{{#!ini
    251245[trac]
    252246authz_file = /path/to/svnaccessfile
     
    255249If you want to support the use of the `[`''modulename''`:/`''some''`/`''path''`]` syntax within the `authz_file`, add
    256250
    257 {{{
     251{{{#!ini
    258252authz_module_name = modulename
    259253}}}
     
    261255where ''modulename'' refers to the same repository indicated by the `<name>.dir` entry in the `[repositories]` section. As an example, if the `blahblah.dir` entry in the `[repositories]` section is `/srv/active/svn/blahblah`, that would yield the following:
    262256
    263 {{{
     257{{{ #!ini
    264258[trac]
    265259authz_file = /path/to/svnaccessfile
     
    276270As of version 0.12, make sure you have ''!AuthzSourcePolicy'' included in the permission_policies list in trac.ini, otherwise the authz permissions file will be ignored.
    277271
    278 {{{ 
     272{{{#!ini
    279273[trac]
    280274permission_policies = AuthzSourcePolicy, ReadonlyWikiPolicy, DefaultPermissionPolicy, LegacyAttachmentPolicy
     
    284278
    285279The same access file is typically applied to the corresponding Subversion repository using an Apache directive like this:
    286 {{{
     280{{{#!apache
    287281<Location /repos>
    288282  DAV svn
     
    327321== Debugging permissions
    328322In trac.ini set:
    329 {{{
     323{{{#!ini
    330324[logging]
    331325log_file = trac.log
     
    335329
    336330And watch:
    337 {{{
     331{{{#!sh
    338332tail -n 0 -f log/trac.log | egrep '\[perm\]|\[authz_policy\]'
    339333}}}