@@ -1694,6 +1694,7 @@ A set of Permissions is built into the security module by default:
16941694
16951695- Create (everything)
16961696- Edit (everything)
1697+ - Search (everything) (used if View does not permit access)
16971698- View (everything)
16981699- Register (User class only)
16991700
@@ -1721,7 +1722,7 @@ also define:
17211722
17221723These are hooked into the default Roles:
17231724
1724- - Admin (Create, Edit, View and everything; Web Roles)
1725+ - Admin (Create, Edit, Search, View and everything; Web Roles)
17251726- User (Web Access; Email Access)
17261727- Anonymous (Web Access)
17271728
@@ -1760,7 +1761,7 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
17601761
17611762 # Assign the access and edit Permissions for issue, file and message
17621763 # to regular users now
1763- for cl in 'issue', 'file', 'msg', 'query', ' keyword':
1764+ for cl in 'issue', 'file', 'msg', 'keyword':
17641765 db.security.addPermissionToRole('User', 'View', cl)
17651766 db.security.addPermissionToRole('User', 'Edit', cl)
17661767 db.security.addPermissionToRole('User', 'Create', cl)
@@ -1769,21 +1770,52 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
17691770
17701771 # May users view other user information? Comment these lines out
17711772 # if you don't want them to
1772- db.security.addPermissionToRole('User', 'View', 'user')
1773+ p = db.security.addPermission(name='View', klass='user',
1774+ properties=('id', 'organisation', 'phone', 'realname', 'timezone',
1775+ 'username'))
1776+ db.security.addPermissionToRole('User', p)
17731777
1774- # Users should be able to edit their own details -- this permission
1775- # is limited to only the situation where the Viewed or Edited item
1776- # is their own.
1778+ # Users should be able to edit their own details -- this permission is
1779+ # limited to only the situation where the Viewed or Edited item is their own.
17771780 def own_record(db, userid, itemid, **ctx):
17781781 '''Determine whether the userid matches the item being accessed.'''
17791782 return userid == itemid
17801783 p = db.security.addPermission(name='View', klass='user', check=own_record,
17811784 description="User is allowed to view their own user details")
17821785 db.security.addPermissionToRole('User', p)
17831786 p = db.security.addPermission(name='Edit', klass='user', check=own_record,
1787+ properties=('username', 'password', 'address', 'realname', 'phone',
1788+ 'organisation', 'alternate_addresses', 'queries', 'timezone'),
17841789 description="User is allowed to edit their own user details")
17851790 db.security.addPermissionToRole('User', p)
17861791
1792+ # Users should be able to edit and view their own queries. They should also
1793+ # be able to view any marked as not private. They should not be able to
1794+ # edit others' queries, even if they're not private
1795+ def view_query(db, userid, itemid):
1796+ private_for = db.query.get(itemid, 'private_for')
1797+ if not private_for: return True
1798+ return userid == private_for
1799+ def edit_query(db, userid, itemid):
1800+ return userid == db.query.get(itemid, 'creator')
1801+ p = db.security.addPermission(name='View', klass='query', check=view_query,
1802+ description="User is allowed to view their own and public queries")
1803+ db.security.addPermissionToRole('User', p)
1804+ p = db.security.addPermission(name='Search', klass='query')
1805+ db.security.addPermissionToRole('User', p)
1806+ p = db.security.addPermission(name='Edit', klass='query', check=edit_query,
1807+ description="User is allowed to edit their queries")
1808+ db.security.addPermissionToRole('User', p)
1809+ p = db.security.addPermission(name='Retire', klass='query', check=edit_query,
1810+ description="User is allowed to retire their queries")
1811+ db.security.addPermissionToRole('User', p)
1812+ p = db.security.addPermission(name='Restore', klass='query', check=edit_query,
1813+ description="User is allowed to restore their queries")
1814+ db.security.addPermissionToRole('User', p)
1815+ p = db.security.addPermission(name='Create', klass='query',
1816+ description="User is allowed to create queries")
1817+ db.security.addPermissionToRole('User', p)
1818+
17871819 #
17881820 # ANONYMOUS USER PERMISSIONS
17891821 #
@@ -1802,13 +1834,21 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
18021834 # Assign the appropriate permissions to the anonymous user's Anonymous
18031835 # Role. Choices here are:
18041836 # - Allow anonymous users to register
1805- db.security.addPermissionToRole('Anonymous', 'Create ', 'user')
1837+ db.security.addPermissionToRole('Anonymous', 'Register ', 'user')
18061838
18071839 # Allow anonymous users access to view issues (and the related, linked
18081840 # information)
18091841 for cl in 'issue', 'file', 'msg', 'keyword', 'priority', 'status':
18101842 db.security.addPermissionToRole('Anonymous', 'View', cl)
18111843
1844+ # Allow the anonymous user to use the "Show Unassigned" search.
1845+ # It acts like "Show Open" if this permission is not available.
1846+ # If you are running a tracker that does not allow read access for
1847+ # anonymous, you should remove this entry as it can be used to perform
1848+ # a username guessing attack against a roundup install.
1849+ p = db.security.addPermission(name='Search', klass='user')
1850+ db.security.addPermissionToRole ('Anonymous', p)
1851+
18121852 # [OPTIONAL]
18131853 # Allow anonymous users access to create or edit "issue" items (and the
18141854 # related file and message items)
0 commit comments