--- python-bugzilla-3.2.0.orig/bugzilla/base.py 2022-01-12 19:09:08.000000000 +0100 +++ python-bugzilla-3.2.0/bugzilla/base.py 2022-12-21 09:32:01.324613243 +0100 @@ -174,7 +174,8 @@ def __init__(self, url=-1, user=None, password=None, cookiefile=-1, sslverify=True, tokenfile=-1, use_creds=True, api_key=None, cert=None, configpaths=-1, - force_rest=False, force_xmlrpc=False, requests_session=None): + force_rest=False, force_xmlrpc=False, requests_session=None, + basic_auth=False): """ :param url: The bugzilla instance URL, which we will connect to immediately. Most users will want to specify this at @@ -207,6 +208,7 @@ :param requests_session: An optional requests.Session object the API will use to contact the remote bugzilla instance. This way the API user can set up whatever auth bits they may need. + :param basic_auth: Use headers with HTTP Basic authentication """ if url == -1: raise TypeError("Specify a valid bugzilla url, or pass url=None") @@ -246,6 +248,7 @@ self._settokenfile(tokenfile) self._setconfigpath(configpaths) + self._basic_auth = basic_auth if url: self.connect(url) @@ -598,6 +601,8 @@ raise ValueError("missing username") if not self.password: raise ValueError("missing password") + if self._basic_auth: + self._backend.set_basic_auth(self.user, self.password) payload = {"login": self.user} if restrict_login: --- python-bugzilla-3.2.0.orig/bugzilla/_backendxmlrpc.py 2022-01-12 19:09:08.000000000 +0100 +++ python-bugzilla-3.2.0/bugzilla/_backendxmlrpc.py 2022-12-21 09:35:40.471278786 +0100 @@ -2,6 +2,7 @@ # See the COPYING file in the top-level directory. from logging import getLogger +import base64 import sys from xmlrpc.client import (Binary, Fault, ProtocolError, ServerProxy, Transport) @@ -127,6 +128,9 @@ # pylint: enable=no-member return ret + + def clear_token(self): + self.__bugzillasession.set_token_value(None) class _BackendXMLRPC(_BackendBase): @@ -142,6 +146,16 @@ def is_xmlrpc(self): return True + def set_basic_auth(self, user, password): + """ + Set basic authentication method. + + :return: + """ + b64str = base64.b64encode("{}:{}".format(user, password).encode("utf-8")) + authstr = "Basic {}".format(b64str.decode("utf-8")) + self._bugzillasession._session.headers["Authorization"] = authstr + def bugzilla_version(self): return self._xmlrpc_proxy.Bugzilla.version()