diff --git a/examples/reference-gertty.yaml b/examples/reference-gertty.yaml index 2281bc7..bc959ba 100644 --- a/examples/reference-gertty.yaml +++ b/examples/reference-gertty.yaml @@ -23,6 +23,10 @@ servers: # username: CHANGEME # Your password in Gerrit (Settings -> HTTP Password). [required] # password: CHANGEME +# Authentication type required by the Gerrit server. Can be 'basic' or +# 'digest'. Defaults to 'digest' if not set or set to an unexpected +# value. +# auth-type: digest # A location where Gertty should store its git repositories. These # can be the same git repositories where you do your own work -- # Gertty will not modify them unless you tell it to, and even then the diff --git a/gertty/config.py b/gertty/config.py index 9abf193..db0b9e3 100644 --- a/gertty/config.py +++ b/gertty/config.py @@ -45,6 +45,7 @@ class ConfigSchema(object): 'dburi': str, v.Required('git-root'): str, 'log-file': str, + 'auth-type': str, } servers = [server] @@ -133,6 +134,10 @@ class Config(object): if self.password is None: self.password = getpass.getpass("Password for %s (%s): " % (self.url, self.username)) + self.auth_type = server.get('auth-type', 'digest') + auth_types = ['digest', 'basic'] + if self.auth_type not in auth_types: + self.auth_type = 'digest' self.verify_ssl = server.get('verify-ssl', True) if not self.verify_ssl: os.environ['GIT_SSL_NO_VERIFY']='true' diff --git a/gertty/sync.py b/gertty/sync.py index 550317a..8b4fc7a 100644 --- a/gertty/sync.py +++ b/gertty/sync.py @@ -762,7 +762,11 @@ class Sync(object): self.log = logging.getLogger('gertty.sync') self.queue = MultiQueue([HIGH_PRIORITY, NORMAL_PRIORITY, LOW_PRIORITY]) self.session = requests.Session() - self.auth = requests.auth.HTTPDigestAuth( + if self.app.config.auth_type == 'basic': + authclass = requests.auth.HTTPBasicAuth + else: + authclass = requests.auth.HTTPDigestAuth + self.auth = authclass( self.app.config.username, self.app.config.password) self.submitTask(SyncOwnAccountTask(HIGH_PRIORITY)) self.submitTask(CheckReposTask(HIGH_PRIORITY))