Skip to content

Commit 13b8a05

Browse files
committed
session: Only set api_key query param for REST
XMLRPC sends it in the POST payload. This makes it less likely that the API key will leak into error messages: https://bugzilla.redhat.com/show_bug.cgi?id=1896791 Signed-off-by: Cole Robinson <[email protected]>
1 parent 3f974a6 commit 13b8a05

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bugzilla/_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def __init__(self, url, user_agent,
4242
if sslverify is False:
4343
self._session.verify = False
4444
self._session.headers["User-Agent"] = self._user_agent
45-
self._session.params["Bugzilla_api_key"] = self._api_key
4645
self._set_tokencache_param()
4746

4847
def _get_timeout(self):
@@ -55,6 +54,10 @@ def _get_timeout(self):
5554

5655
def set_rest_defaults(self):
5756
self._session.headers["Content-Type"] = "application/json"
57+
# Bugzilla 5.0 only supports api_key as a query parameter.
58+
# Bugzilla 5.1+ takes it as a X-BUGZILLA-API-KEY header as well,
59+
# with query param taking preference.
60+
self._session.params["Bugzilla_api_key"] = self._api_key
5861
def set_xmlrpc_defaults(self):
5962
self._is_xmlrpc = True
6063
self._session.headers["Content-Type"] = "text/xml"

0 commit comments

Comments
 (0)