@@ -682,8 +682,8 @@ returned. You can limit this by using the ``@fields`` query parameter
682682similar to how it is used in collections. This way you can only return
683683the fields you are interested in reducing network load as well as
684684memory and parsing time on the client side. By default protected
685- properties (read only in the database) are not listed. Th
686- is makes it easier to submit the attributes from a
685+ properties (read only in the database) are not listed. This
686+ makes it easier to submit the attributes from a
687687``@verbose=0`` query using PUT. To include protected properties
688688in the output of a GET add the query parameter
689689``@protected=true`` to the query and attributes like: actor,
@@ -862,7 +862,7 @@ payload:
862862
863863produces::
864864
865- {"data": {"attribute": {}, "type": "issue",
865+ {"data": {"attribute": {... }, "type": "issue",
866866 "link": "https://...", "id": "23"}}
867867
868868the lines are wrapped for display purposes, in real life it's one long
@@ -1401,7 +1401,7 @@ your company's single sign on infrastructure.
14011401
14021402So what we need is a way for this third part service to impersonate
14031403you and have access to create a roundup timelog entry (see
1404- `<customizing.html#adding-a-time-log-to-your-issues>`__. Then add it
1404+ `<customizing.html#adding-a-time-log-to-your-issues>`__) . Then add it
14051405to the associated issue. This should happen without sharing passwords
14061406and without the third party service to see the issue (except the
14071407``times`` property), user, or other information in the tracker.
@@ -1413,41 +1413,66 @@ There are 5 steps to set this up:
14131413
141414141. install pyjwt library using pip or pip3. If roundup can't find the
14151415 jwt module you will see the error ``Support for jwt disabled.``
1416- 2. create a new role that allows Create access to timelog and edit
1416+ 2. create a new role that allows Create access to timelog and edit/view
14171417 access to an issues' ``times`` property.
141814183. add support for issuing (and validating) jwts to the rest interface.
14191419 This uses the `Adding new rest endpoints`_ mechanism.
142014204. configure roundup's config.ini [web] jwt_secret with at least 32
14211421 random characters of data. (You will get a message
14221422 ``Support for jwt disabled by admin.`` if it's not long enough.)
142314235. add an auditor to make sure that users with this role are appending
1424- timelog links to the `times` property of the issue.
1424+ timelog links to the `` times` ` property of the issue.
14251425
14261426Create role
14271427"""""""""""
14281428
14291429Adding this snippet of code to the tracker's ``schema.py`` should create a role with the
14301430proper authorization::
14311431
1432- db.security.addRole(name="User:timelog", description="allow a user to create and append timelogs")
1432+ db.security.addRole(name="User:timelog",
1433+ description="allow a user to create and append timelogs")
1434+
1435+ db.security.addPermissionToRole('User:timelog', 'Rest Access')
1436+
14331437 perm = db.security.addPermission(name='Create', klass='timelog',
14341438 description="Allow timelog creation", props_only=False)
14351439 db.security.addPermissionToRole("User:timelog", perm)
1440+
1441+ perm = db.security.addPermission(name='View', klass='issue',
1442+ properties=('id', 'times'),
1443+ description="Allow timelog retreival for issue",
1444+ props_only=False)
1445+ db.security.addPermissionToRole("User:timelog", perm)
1446+
14361447 perm = db.security.addPermission(name='Edit', klass='issue',
14371448 properties=('id', 'times'),
14381449 description="Allow editing timelog for issue", props_only=False)
14391450 db.security.addPermissionToRole("User:timelog", perm)
1440- db.security.addPermissionToRole('User:timelog', 'Rest Access')
14411451
1442- Then role is named to work with the jwt issue rest call. Starting the role
1443- name with ``User:`` allows the jwt issue code to create a token with
1444- this role if the user requesting the role has the User role.
1452+ The role is named to work with the /rest/jwt/issue rest endpoint
1453+ defined below. Starting the role name with ``User:`` allows the jwt
1454+ issue code to create a token with this role if the user requesting the
1455+ role has the User role.
1456+
1457+ The role *must* have access to the issue ``id`` to retrieve the etag for
1458+ the issue. The etag is passed in the ``If-Match`` HTTP header when you
1459+ make a call to patch or update the ``timess` property of the issue.
1460+
1461+ If you use a PATCH rest call with "@op=add" to append the new timelog,
1462+ you don't need View access to the ``times`` property. If you replace the
1463+ ``times`` value, you need to read the current value of ``times`` (using
1464+ View permission), append the newly created timelog id to the (array)
1465+ value, and replace the ``times`` value.
1466+
1467+ Note that the json returned after the operation will include the new
1468+ value of the ``times`` value so your code can verify that it worked.
1469+ This does potentially leak info about the previous id's in the field.
14451470
14461471Create rest endpoints
14471472"""""""""""""""""""""
14481473
1449- Here is code to add to your tracker's ``interfaces.py`` (note code is
1450- python3)::
1474+ Here is code to add to your tracker's ``interfaces.py`` (note code has
1475+ only been tested with python3)::
14511476
14521477 from roundup.rest import Routing, RestfulInstance, _data_decorator
14531478
0 commit comments