Skip to content

Commit 5635e13

Browse files
committed
Add "rest" and "xmlrpc" values for database tx_Source property
issue2551059: added new values for tx_Source to indicate when /rest or /xmlrpc endpoint is being used rather than the html web interface.
1 parent 04e2b53 commit 5635e13

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ Features:
9494
- issue2551058: Add new permissions: 'Rest Access' and 'Xmlrpc Access'
9595
to allow per-user access control to rest and xmlrpc interfaces using
9696
roles.
97-
97+
- issue2551059: added new values for tx_Source to indicate when /rest
98+
or /xmlrpc endpoint is being used rather than the normal web
99+
endpoints. (John Rouillard)
100+
98101
Fixed:
99102

100103
- issue2550811: work around Unicode encoding issues in jinja2 template

doc/customizing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ directory of your tracker::
49234923
# the nosy field has not changed so no need to check.
49244924
return
49254925

4926-
if db.tx_Source in ['web', 'email-sig-openpgp', 'cli' ]:
4926+
if db.tx_Source in ['web', 'rest', 'xmlrpc', 'email-sig-openpgp', 'cli' ]:
49274927
# if the source of the transaction is from an authenticated
49284928
# source or a privileged process allow the transaction.
49294929
# Other possible sources: 'email'

doc/upgrading.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,30 @@ tracker's schema.py and add::
6464
This is usually included near where other permissions like "Web Access"
6565
or "Email Access" are assigned.
6666

67+
New values for db.tx_Source
68+
---------------------------
69+
70+
The database attribute tx_Source reports "xmlrpc" and "rest" when the
71+
/xmlrpc and /rest web endpoints are used. Check all code (extensions,
72+
detectors, lib) in trackers looking for tx_Source. If you have code
73+
like::
74+
75+
if db.tx_Source == "web":
76+
77+
or::
78+
79+
if db.tx_Source in ['web', 'email-sig-openpgp', 'cli' ]:
80+
81+
you may need to change these to include matches to "rest" and
82+
"xmlrpc". For example::
83+
84+
if db.tx_Source in [ "web", "rest", "xmlrpc" ]
85+
86+
or::
87+
88+
if db.tx_Source in ['web', 'rest', 'xmlrpc', 'email-sig-openpgp', 'cli' ]:
89+
90+
6791
Python 3 support
6892
----------------
6993

roundup/cgi/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ def handle_xmlrpc(self):
503503
# Open the database as the correct user.
504504
try:
505505
self.determine_user()
506+
self.db.tx_Source = "xmlrpc"
506507
except LoginError as msg:
507508
output = xmlrpc_.client.dumps(
508509
xmlrpc_.client.Fault(401, "%s" % msg),
@@ -557,6 +558,7 @@ def handle_rest(self):
557558
# TODO: add everything to RestfulDispatcher
558559
try:
559560
self.determine_user()
561+
self.db.tx_Source = "rest"
560562
except LoginError as err:
561563
self.response_code = http_.client.UNAUTHORIZED
562564
output = s2b("Invalid Login - %s"%str(err))

test/tx_Source_detector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def tx_SourceCheckAudit(db, cl, nodeid, newvalues):
2626
None - Reported when using a script or it is an error if
2727
the change arrives by another method.
2828
"cli" - reported when using roundup-admin
29-
"web" - reported when using any web based technique
29+
"web" - reported when using html based web pages
30+
"rest" - reported when using the /rest web API
31+
"xmlrpc" - reported when using the /xmlrpc web API
3032
"email" - reported when using an unautheticated email based technique
3133
"email-sig-openpgp" - reported when email with a valid pgp
3234
signature is used
@@ -51,7 +53,9 @@ def tx_SourceCheckReact(db, cl, nodeid, oldvalues):
5153
None - Reported when using a script or it is an error if
5254
the change arrives by another method.
5355
"cli" - reported when using roundup-admin
54-
"web" - reported when using any web based technique
56+
"web" - reported when using html based web pages
57+
"rest" - reported when using the /rest web API
58+
"xmlrpc" - reported when using the /xmlrpc web API
5559
"email" - reported when using an unautheticated email based technique
5660
"email-sig-openpgp" - reported when email with a valid pgp
5761
signature is used

0 commit comments

Comments
 (0)