Skip to content

Commit 5322210

Browse files
committed
Documentation and fix for REST headers
issue2551372 - Better document necessary headers for REST and fix logging to log missing Origin header.
1 parent b9a52fa commit 5322210

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Fixed:
3030
to a red error msg. (Report by Ludwig Reiter; fix John Rouillard)
3131
- issue2550698 - added documentation on filtering using RPN property
3232
expressions. (John Rouillard)
33+
- issue2551372 - Better document necessary headers for REST and fix
34+
logging to log missing Origin header (Ralf Schlatterbeck with
35+
suggestions on documentation by John Rouillard)
3336

3437
Features:
3538

doc/rest.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ explicitly set.)
6868
Preventing CSRF Attacks
6969
-----------------------
7070

71-
Clients should set the header X-REQUESTED-WITH to any value and the
71+
Clients should set the header ``X-REQUESTED-WITH`` to any value and the
7272
tracker's config.ini should have ``csrf_enforce_header_x-requested-with
7373
= yes`` or ``required``.
7474

@@ -77,6 +77,12 @@ that is not hosted at the same origin as Roundup, you must permit
7777
the origin using the ``allowed_api_origins`` setting in
7878
``config.ini``.
7979

80+
If you access the REST interface with a method other than ``GET``, you
81+
must also supply an origin header with a value that is either the
82+
default origin (the URL of the tracker without the path component set in
83+
the config file as ``web`` in section ``[tracker]``) or one that is
84+
permitted by ``allowed_api_origins``.
85+
8086
Rate Limiting API Failed Logins
8187
-------------------------------
8288

roundup/cgi/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,10 @@ def handle_rest(self):
719719
if not self.is_origin_header_ok(api=True):
720720
if 'HTTP_ORIGIN' not in self.env:
721721
msg = self._("Required Header Missing")
722+
err = 'Origin header missing'
722723
else:
723724
msg = self._("Client is not allowed to use Rest Interface.")
725+
err = 'Unauthorized for REST request'
724726

725727
# Use code 400. Codes 401 and 403 imply that authentication
726728
# is needed or authenticated person is not authorized.
@@ -730,6 +732,7 @@ def handle_rest(self):
730732
self.reject_request(output,
731733
message_type="application/json",
732734
status=400)
735+
logger.error(err)
733736
return
734737

735738
# Handle CORS preflight request. We know rest is enabled

0 commit comments

Comments
 (0)