Changes between Version 1 and Version 2 of TracPermissions


Ignore:
Timestamp:
2023-04-20T18:30:58Z (19 months ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracPermissions

    v1 v2  
    1 = Trac Permissions =
     1= Trac Permissions
    22[[TracGuideToc]]
    33
    44Trac uses a simple, case sensitive, permission system to control what users can and can't access.
    55
    6 Permission privileges are managed using the [TracAdmin trac-admin] tool or (new in version 0.11) the ''General / Permissions'' panel in the ''Admin'' tab of the web interface.
    7 
    8 In addition to the default permission policy described in this page, it is possible to activate additional permission policies by enabling plugins and listing them in the `[trac] permission_policies` configuration entry in the TracIni. See TracFineGrainedPermissions for more details.
    9 
    10 Non-authenticated users accessing the system are assigned the name "anonymous". Assign permissions to the "anonymous" user to set privileges for anonymous/guest users. The parts of Trac that a user does not have the privileges for will not be displayed in the navigation.
    11 In addition to these privileges, users can be granted additional individual rights in effect when authenticated and logged into the system. All logged in users belong to the virtual group "authenticated", which inherits permissions from "anonymous".
    12 
    13 == Graphical Admin Tab ==
    14 ''This feature is new in version 0.11.''
    15 
    16 To access this tab, a user must have `TRAC_ADMIN privileges`. This can be performed as follows (more on the trac-admin script below):
    17 {{{
    18   $ trac-admin /path/to/projenv permission add bob TRAC_ADMIN
    19 }}}
    20 
    21 Then, the user `bob` will be able to see the Admin tab, and can then access the permissions menu. This menu will allow you to perform all the following actions, but from the browser without requiring root access to the server (just the correct permissions for your user account).
    22 
    23 
    24 An easy way to quickly secure a new Trac install is to run the above command on the anonymous user, install the [http://trac-hacks.org/wiki/AccountManagerPlugin AccountManagerPlugin], create a new admin account graphically and then remove the TRAC_ADMIN permission from the anonymous user.
    25 
    26 == Available Privileges ==
    27 
    28 To enable all privileges for a user, use the `TRAC_ADMIN` permission. Having `TRAC_ADMIN` is like being `root` on a *NIX system: it will allow you to perform any operation.
    29 
    30 Otherwise, individual privileges can be assigned to users for the various different functional areas of Trac ('''note that the privilege names are case-sensitive'''):
    31 
    32 === Repository Browser ===
    33 
    34 || `BROWSER_VIEW` || View directory listings in the [wiki:TracBrowser repository browser] ||
    35 || `LOG_VIEW` || View revision logs of files and directories in the [wiki:TracBrowser repository browser] ||
    36 || `FILE_VIEW` || View files in the [wiki:TracBrowser repository browser] ||
    37 || `CHANGESET_VIEW` || View [wiki:TracChangeset repository check-ins] ||
    38 
    39 === Ticket System ===
    40 
    41 || `TICKET_VIEW` || View existing [wiki:TracTickets tickets] and perform [wiki:TracQuery ticket queries] ||
    42 || `TICKET_CREATE` || Create new [wiki:TracTickets tickets] ||
    43 || `TICKET_APPEND` || Add comments or attachments to [wiki:TracTickets tickets] ||
    44 || `TICKET_CHGPROP` || Modify [wiki:TracTickets ticket] properties (priority, assignment, keywords, etc.) with the following exceptions: edit description field, add/remove other users from cc field when logged in, and set email to pref ||
    45 || `TICKET_MODIFY` || Includes both `TICKET_APPEND` and `TICKET_CHGPROP`, and in addition allows resolving [wiki:TracTickets tickets]. Tickets can be assigned to users through a [TracTickets#Assign-toasDrop-DownList drop-down list] when the list of possible owners has been restricted. ||
     6Permissions are managed using the [TracAdmin trac-admin] tool or the ''General / Permissions'' panel in the ''Admin'' tab of the web interface.
     7
     8In addition to the default permission policy described in this page, it is possible to activate additional permission policies by enabling plugins and listing them in [TracIni#trac-permission_policies-option "[trac] permission_policies"]. See TracFineGrainedPermissions for more details.
     9
     10Non-authenticated users accessing the system are assigned the name //anonymous//. Assign permissions to the //anonymous// user to set privileges for anonymous/guest users. The parts of Trac that a user does not have privileges for will not be displayed in the navigation bar.
     11In addition to these privileges, users can be granted additional individual rights in effect when authenticated and logged into the system. All logged in users belong to the virtual group //authenticated//, which inherits permissions from //anonymous//.
     12
     13== Graphical Admin Tab
     14
     15To access this tab, a user must have one of the following permissions: `TRAC_ADMIN`, `PERMISSION_ADMIN`, `PERMISSION_GRANT`, `PERMISSION_REVOKE`. The permissions can be granted using the `trac-admin` command with a more detailed description [#GrantingPrivileges below]:
     16{{{#!sh
     17$ trac-admin /path/to/projenv permission add bob TRAC_ADMIN
     18}}}
     19
     20Then, the user `bob` will be able to see the Admin tab, and can access the permissions menu. This menu allows you to perform the following actions, but from the browser rather than requiring root access to the server. '''Use at least one lowercase character in user names, as all-uppercase names are reserved for permissions.'''
     21
     22[[Image(htdocs:../common/guide/admin.png)]]
     23
     24[[Image(htdocs:../common/guide/admin-permissions.png)]]
     25
     26[[Image(htdocs:../common/guide/admin-permissions-TICKET_ADMIN.png)]]
     27
     28From the graphical admin tab, users with `PERMISSION_GRANT` will only be allowed to grant permissions that they possess, and users with `PERMISSION_REVOKE` will only be allowed to revoke permissions that they possess. For example, a user cannot grant `MILESTONE_ADMIN` unless they have `PERMISSION_GRANT` and `MILESTONE_ADMIN`, and they cannot revoke `MILESTONE_ADMIN` unless they have `PERMISSION_REVOKE` and `MILESTONE_ADMIN`. `PERMISSION_ADMIN` just grants the user both `PERMISSION_GRANT` and `PERMISSION_REVOKE`, and users with `TRAC_ADMIN` can grant or revoke any permission.
     29
     30== Available Privileges
     31
     32To enable all privileges for a user, use the `TRAC_ADMIN` permission. This permission is like being `root` on a *NIX system: it will allow you to perform any operation on Trac.
     33
     34Otherwise, individual privileges can be assigned to users for the different functional areas of Trac and '''note that the privilege names are uppercase''':
     35
     36=== Repository Browser
     37
     38|| `BROWSER_VIEW` || View directory listings in the [TracBrowser repository browser] ||
     39|| `FILE_VIEW` || View files in the [TracBrowser repository browser] ||
     40|| `CHANGESET_VIEW` || View [TracChangeset repository check-ins] ||
     41|| `LOG_VIEW` || View revision logs of files and directories in the [TracBrowser repository browser] ||
     42
     43=== Ticket System
     44
     45|| `TICKET_VIEW` || View existing [TracTickets tickets] and perform [TracQuery ticket queries] ||
     46|| `TICKET_CREATE` || Create new [TracTickets tickets] ||
     47|| `TICKET_APPEND` || Add comments and attachments to [TracTickets tickets], and edit description of ticket that the user created ||
     48|| `TICKET_CHGPROP` || Modify [TracTickets ticket] properties (priority, assignment, keywords, etc.) with the following exceptions: edit description of tickets created by others, add/remove other users from cc field when logged in ||
     49|| `TICKET_MODIFY` || Includes both `TICKET_APPEND` and `TICKET_CHGPROP`, and in addition allows resolving [TracTickets tickets] in the [TracWorkflow default workflow]. Tickets can be assigned to users through a [TracTickets#Assign-toasDrop-DownList drop-down list] when the list of possible owners has been restricted. ||
    4650|| `TICKET_EDIT_CC` || Full modify cc field ||
    47 || `TICKET_EDIT_DESCRIPTION` || Modify description field ||
    48 || `TICKET_ADMIN` || All `TICKET_*` permissions, plus the deletion of ticket attachments and modification of the reporter and description fields. It also allows managing ticket properties in the WebAdmin panel. ||
    49 
    50 Attention: the "view tickets" button appears with the `REPORT_VIEW` permission.
    51 
    52 === Roadmap ===
     51|| `TICKET_EDIT_DESCRIPTION` || Modify description field. User with `TICKET_APPEND` or `TICKET_CHGPROP` can modify description of ticket they created. ||
     52|| `TICKET_EDIT_COMMENT` || Modify another user's comments. Any user can modify their own comments by default. ||
     53|| `TICKET_BATCH_MODIFY` || [TracBatchModify Batch modify] tickets ||
     54|| `TICKET_ADMIN` || All `TICKET_*` permissions, deletion of ticket attachments and modification of the reporter field, which grants ability to create a ticket on behalf of another user and it will appear that another user created the ticket. It also allows managing ticket properties through the web administration module. ||
     55
     56=== Roadmap
    5357
    5458|| `MILESTONE_VIEW` || View milestones and assign tickets to milestones. ||
    55 || `MILESTONE_CREATE` || Create a new milestone ||
    56 || `MILESTONE_MODIFY` || Modify existing milestones ||
     59|| `MILESTONE_CREATE` || Create new milestones ||
     60|| `MILESTONE_MODIFY` || Modify milestones ||
    5761|| `MILESTONE_DELETE` || Delete milestones ||
    5862|| `MILESTONE_ADMIN` || All `MILESTONE_*` permissions ||
    59 || `ROADMAP_VIEW` || View the [wiki:TracRoadmap roadmap] page, is not (yet) the same as MILESTONE_VIEW, see [trac:#4292 #4292] ||
    60 || `ROADMAP_ADMIN` || to be removed with [trac:#3022 #3022], replaced by MILESTONE_ADMIN ||
    61 
    62 === Reports ===
    63 
    64 || `REPORT_VIEW` || View [wiki:TracReports reports], i.e. the "view tickets" link. ||
    65 || `REPORT_SQL_VIEW` || View the underlying SQL query of a [wiki:TracReports report] ||
    66 || `REPORT_CREATE` || Create new [wiki:TracReports reports] ||
    67 || `REPORT_MODIFY` || Modify existing [wiki:TracReports reports] ||
    68 || `REPORT_DELETE` || Delete [wiki:TracReports reports] ||
     63|| `ROADMAP_VIEW` || View the [TracRoadmap roadmap] page, which is not yet the same as MILESTONE_VIEW, see [trac:#4292 #4292] ||
     64|| `ROADMAP_ADMIN` || To be removed with [trac:#3022 #3022], replaced by MILESTONE_ADMIN ||
     65
     66=== Reports
     67
     68|| `REPORT_VIEW` || View [TracReports reports], i.e. the //View Tickets// link. ||
     69|| `REPORT_SQL_VIEW` || View the SQL query of a [TracReports report] ||
     70|| `REPORT_CREATE` || Create new [TracReports reports] ||
     71|| `REPORT_MODIFY` || Modify [TracReports reports] ||
     72|| `REPORT_DELETE` || Delete [TracReports reports] ||
    6973|| `REPORT_ADMIN` || All `REPORT_*` permissions ||
    7074
    71 === Wiki System ===
    72 
    73 || `WIKI_VIEW` || View existing [wiki:TracWiki wiki] pages ||
    74 || `WIKI_CREATE` || Create new [wiki:TracWiki wiki] pages ||
    75 || `WIKI_MODIFY` || Change [wiki:TracWiki wiki] pages ||
    76 || `WIKI_DELETE` || Delete [wiki:TracWiki wiki] pages and attachments ||
     75=== Wiki System
     76
     77|| `WIKI_VIEW` || View [TracWiki wiki] pages ||
     78|| `WIKI_CREATE` || Create new [TracWiki wiki] pages ||
     79|| `WIKI_MODIFY` || Modify [TracWiki wiki] pages ||
     80|| `WIKI_RENAME` || Rename [TracWiki wiki] pages ||
     81|| `WIKI_DELETE` || Delete [TracWiki wiki] pages and attachments ||
    7782|| `WIKI_ADMIN` || All `WIKI_*` permissions, plus the management of ''readonly'' pages. ||
    7883
    79 === Permissions ===
     84=== Permissions
    8085
    8186|| `PERMISSION_GRANT` || add/grant a permission ||
     
    8388|| `PERMISSION_ADMIN` || All `PERMISSION_*` permissions ||
    8489
    85 
    86 === Others ===
    87 
    88 || `TIMELINE_VIEW` || View the [wiki:TracTimeline timeline] page ||
    89 || `SEARCH_VIEW` || View and execute [wiki:TracSearch search] queries ||
    90 || `CONFIG_VIEW` || Enables additional pages on ''About Trac'' that show the current configuration or the list of installed plugins ||
    91 || `EMAIL_VIEW` || Shows email addresses even if [trac:wiki:0.11/TracIni trac show_email_addresses configuration option is false] ||
    92 
    93 == Granting Privileges ==
    94 
    95 You grant privileges to users using [wiki:TracAdmin trac-admin]. The current set of privileges can be listed with the following command:
     90=== Others
     91
     92|| `TIMELINE_VIEW` || View the [TracTimeline timeline] page ||
     93|| `SEARCH_VIEW` || View and execute [TracSearch search] queries ||
     94|| `CONFIG_VIEW` || Enables additional sections on ''About Trac'' that show the current configuration and the list of installed plugins ||
     95|| `EMAIL_VIEW` || Shows email addresses even if [TracIni#trac-section trac show_email_addresses] configuration option is false ||
     96
     97== Attachment Permissions
     98
     99Attachment permissions are handled by `LegacyAttachmentPolicy`, and unlike the permissions discussed so far, the permissions provided by `LegacyAttachmentPolicy` are not directly granted. Rather, the ability to create, view and delete attachments is determined by the attachment's parent realm and permissions that the user possesses for that realm.
     100
     101The attachment actions are determined by the following permissions in the ticket, wiki and milestone realms:
     102{{{#!table class="listing"
     103||= Granted By: =||= Ticket =||= Wiki =||= Milestone =||
     104|| `ATTACHMENT_CREATE` || `TICKET_APPEND` || `WIKI_MODIFY` || `MILESTONE_MODIFY` ||
     105|| `ATTACHMENT_VIEW` || `TICKET_VIEW` || `WIKI_VIEW` || `MILESTONE_VIEW` ||
     106|| `ATTACHMENT_DELETE` || `TICKET_ADMIN` || `WIKI_DELETE` || `MILESTONE_DELETE` ||
     107}}}
     108
     109An authenticated user can delete an attachment //they added// without possessing the permission that grants `ATTACHMENT_DELETE`.
     110
     111If explicit attachment permissions are preferred, then `ATTACHMENT_CREATE`, `ATTACHMENT_DELETE` and `ATTACHMENT_VIEW` can be created using the [trac:ExtraPermissionsProvider]. The simplest implementation is to simply define the actions:
     112{{{#!ini
     113[extra-permissions]
     114_perms = ATTACHMENT_CREATE, ATTACHMENT_DELETE, ATTACHMENT_VIEW
     115}}}
     116
     117An alternative configuration adds an `ATTACHMENT_ADMIN` meta-permission that grants the other 3 permissions:
     118{{{#!ini
     119[extra-permissions]
     120ATTACHMENT_ADMIN = ATTACHMENT_CREATE, ATTACHMENT_DELETE, ATTACHMENT_VIEW
     121}}}
     122
     123The explicit permissions can be used in conjunction with `LegacyAttachmentPolicy`, or `LegacyAttachmentPolicy` can be removed from `permission_policies`, in which case only users that have been explicitly granted the corresponding attachment actions will be able to create, delete and view attachments.
     124
     125== Granting Privileges
     126
     127Privileges are granted to users through [TracAdmin trac-admin]. The current set of privileges can be listed with the following command:
     128{{{#!sh
     129$ trac-admin /path/to/projenv permission list
     130}}}
     131
     132This command will allow the user ''bob'' to delete reports:
     133{{{#!sh
     134$ trac-admin /path/to/projenv permission add bob REPORT_DELETE
     135}}}
     136
     137The `permission add` command also accepts multiple privilege names:
     138{{{#!sh
     139$ trac-admin /path/to/projenv permission add bob REPORT_DELETE WIKI_CREATE
     140}}}
     141
     142Or add all privileges:
     143{{{#!sh
     144$ trac-admin /path/to/projenv permission add bob TRAC_ADMIN
     145}}}
     146
     147== Permission Groups
     148
     149There are two built-in groups, //authenticated// and //anonymous//.
     150Any user who has not logged in is automatically in the //anonymous// group.
     151Any user who has logged in is also in the //authenticated// group.
     152The //authenticated// group inherits permissions from the //anonymous// group.
     153For example, if the //anonymous// group has permission `WIKI_MODIFY`, it is not necessary to add the `WIKI_MODIFY` permission to the //authenticated// group as well.
     154
     155Custom groups may be defined that inherit permissions from the two built-in groups.
     156
     157Permissions can be grouped together to form roles such as ''developer'', ''admin'', etc.
     158{{{#!sh
     159$ trac-admin /path/to/projenv permission add developer WIKI_ADMIN
     160$ trac-admin /path/to/projenv permission add developer REPORT_ADMIN
     161$ trac-admin /path/to/projenv permission add developer TICKET_MODIFY
     162$ trac-admin /path/to/projenv permission add bob developer
     163$ trac-admin /path/to/projenv permission add john developer
     164}}}
     165
     166Group membership can be checked by doing a {{{permission list}}} with no further arguments; the resulting output will include group memberships. '''Use at least one lowercase character in group names, as all-uppercase names are reserved for permissions'''.
     167
     168== Adding a New Group and Permissions
     169
     170Permission groups can be created by assigning a user to a group you wish to create, then assign permissions to that group.
     171
     172The following will add ''bob'' to the new group called ''beta_testers'' and then will assign `WIKI_ADMIN` permissions to that group. Thus, ''bob'' will inherit the `WIKI_ADMIN` permission.
     173{{{#!sh
     174$ trac-admin /path/to/projenv permission add bob beta_testers
     175$ trac-admin /path/to/projenv permission add beta_testers WIKI_ADMIN
     176}}}
     177
     178== Removing Permissions
     179
     180Permissions can be removed using the 'remove' command.
     181
     182This command will prevent the user ''bob'' from deleting reports:
     183{{{#!sh
     184$ trac-admin /path/to/projenv permission remove bob REPORT_DELETE
     185}}}
     186
     187Just like `permission add`, this command accepts multiple privilege names.
     188
     189You can also remove all privileges for a specific user:
     190{{{#!sh
     191$ trac-admin /path/to/projenv permission remove bob '*'
     192}}}
     193
     194Or one privilege for all users:
     195{{{#!sh
     196$ trac-admin /path/to/projenv permission remove '*' REPORT_ADMIN
     197}}}
     198
     199== Creating New Privileges
     200
     201To create custom permissions, for example to be used in a custom workflow, enable the optional [trac:ExtraPermissionsProvider tracopt.perm.config_perm_provider.ExtraPermissionsProvider] component in the "Plugins" admin panel, and add the desired permissions to the `[extra-permissions]` section in your [TracIni#extra-permissions-section trac.ini]. For more information, please refer to the documentation  on the [TracIni#extra-permissions-section TracIni] page after enabling the component.
     202
     203== Default Permissions
     204
     205By default on a new Trac installation, the //anonymous// user has ''view'' access to everything in Trac, but is not able to create or modify anything.
     206The //authenticated// user has the permissions to ''create and modify tickets and wiki pages''.
     207
     208//**anonymous**//
    96209{{{
    97   $ trac-admin /path/to/projenv permission list
    98 }}}
    99 
    100 This command will allow the user ''bob'' to delete reports:
     210BROWSER_VIEW
     211CHANGESET_VIEW
     212FILE_VIEW
     213LOG_VIEW
     214MILESTONE_VIEW
     215REPORT_SQL_VIEW
     216REPORT_VIEW
     217ROADMAP_VIEW
     218SEARCH_VIEW
     219TICKET_VIEW
     220TIMELINE_VIEW
     221WIKI_VIEW
     222}}}
     223
     224//**authenticated**//
    101225{{{
    102   $ trac-admin /path/to/projenv permission add bob REPORT_DELETE
    103 }}}
    104 
    105 The `permission add` command also accepts multiple privilege names:
    106 {{{
    107   $ trac-admin /path/to/projenv permission add bob REPORT_DELETE WIKI_CREATE
    108 }}}
    109 
    110 Or add all privileges:
    111 {{{
    112   $ trac-admin /path/to/projenv permission add bob TRAC_ADMIN
    113 }}}
    114 
    115 == Permission Groups ==
    116 
    117 There are two built-in groups, "authenticated" and "anonymous".[[BR]]
    118 Any user who has not logged in is automatically in the "anonymous" group.[[BR]]
    119 Any user who has logged in is also in the "authenticated" group.[[BR]]
    120 The "authenticated" group inherits permissions from the "anonymous" group.[[BR]]
    121 eg. if the "anonymous" group has permission WIKI_MODIFY, it's not necessary to add the WIKI_MODIFY permisison to the "authenticated" group as well.
    122 
    123 Custom groups may be defined that inherit permissions from the two built-in groups.
    124 
    125 Permissions can be grouped together to form roles such as ''developer'', ''admin'', etc.
    126 {{{
    127   $ trac-admin /path/to/projenv permission add developer WIKI_ADMIN
    128   $ trac-admin /path/to/projenv permission add developer REPORT_ADMIN
    129   $ trac-admin /path/to/projenv permission add developer TICKET_MODIFY
    130   $ trac-admin /path/to/projenv permission add bob developer
    131   $ trac-admin /path/to/projenv permission add john developer
    132 }}}
    133 
    134 Group membership can be checked by doing a {{{permission list}}} with no further arguments; the resulting output will include group memberships. '''Use lowercase for group names, as uppercase is reserved for permissions'''.
    135 
    136 == Adding a New Group and Permissions ==
    137 Permission groups can be created by assigning a user to a group you wish to create, then assign permissions to that group.
    138 
    139 The following will add ''bob'' to the new group called ''beta_testers'' and then will assign WIKI_ADMIN permissions to that group. (Thus, ''bob'' will inherit the WIKI_ADMIN permission)
    140 {{{
    141    $ trac-admin /path/to/projenv permission add bob beta_testers
    142    $ trac-admin /path/to/projenv permission add beta_testers WIKI_ADMIN
    143 
    144 }}}
    145 
    146 == Removing Permissions ==
    147 
    148 Permissions can be removed using the 'remove' command. For example:
    149 
    150 This command will prevent the user ''bob'' from deleting reports:
    151 {{{
    152   $ trac-admin /path/to/projenv permission remove bob REPORT_DELETE
    153 }}}
    154 
    155 Just like `permission add`, this command accepts multiple privilege names.
    156 
    157 You can also remove all privileges for a specific user:
    158 {{{
    159   $ trac-admin /path/to/projenv permission remove bob '*'
    160 }}}
    161 
    162 Or one privilege for all users:
    163 {{{
    164   $ trac-admin /path/to/projenv permission remove '*' REPORT_ADMIN
    165 }}}
    166 
    167 == Default Permissions ==
    168 
    169 By default on a new Trac installation, the `anonymous` user will have ''view'' access to everything in Trac, but will not be able to create or modify anything.
    170 On the other hand, the `authenticated` users will have the permissions to ''create and modify tickets and wiki pages''.
    171 
    172 '''anonymous'''
    173 {{{
    174  BROWSER_VIEW
    175  CHANGESET_VIEW
    176  FILE_VIEW
    177  LOG_VIEW
    178  MILESTONE_VIEW
    179  REPORT_SQL_VIEW
    180  REPORT_VIEW
    181  ROADMAP_VIEW
    182  SEARCH_VIEW
    183  TICKET_VIEW
    184  TIMELINE_VIEW
    185  WIKI_VIEW
    186 }}}
    187 
    188 '''authenticated'''
    189 {{{
    190  TICKET_CREATE
    191  TICKET_MODIFY
    192  WIKI_CREATE
    193  WIKI_MODIFY 
    194 }}}
     226TICKET_CREATE
     227TICKET_MODIFY
     228WIKI_CREATE
     229WIKI_MODIFY
     230}}}
     231
    195232----
    196 See also: TracAdmin, TracGuide and TracFineGrainedPermissions
     233See also: TracAdmin, TracFineGrainedPermissions