Support more auth methods in gerrit module
diff --git a/_modules/gerrit.py b/_modules/gerrit.py
index bd21b2e..369c2a2 100644
--- a/_modules/gerrit.py
+++ b/_modules/gerrit.py
@@ -457,11 +457,16 @@
protocol = get('protocol', 'http')
username = get('user', 'admin')
password = get('password', 'admin')
+ auth_method = get('auth_method', 'digest')
url = protocol+"://"+str(host)+':'+str(http_port)
- auth = requests.auth.HTTPDigestAuth(
- username, password)
+ if auth_method == 'digest':
+ auth = requests.auth.HTTPDigestAuth(username, password)
+ elif auth_method == 'basic':
+ auth = requests.auth.HTTPBasicAuth(username, password)
+ else:
+ raise Exception("Unknown auth_method %s" % auth_method)
gerrit = pygerrit.rest.GerritRestAPI(
url=url, auth=auth)
diff --git a/gerrit/files/_gerrit.conf b/gerrit/files/_gerrit.conf
index 85d04df..4cbbec5 100644
--- a/gerrit/files/_gerrit.conf
+++ b/gerrit/files/_gerrit.conf
@@ -2,6 +2,7 @@
gerrit:
host: {{ client.server.host }}
user: {{ client.server.user }}
+ auth_method: {{ client.server.get('auth_method', 'digest')
{%- if client.server.protocol is defined %}
protocol: {{ client.server.protocol }}
{%- endif %}
@@ -13,4 +14,4 @@
{%- endif %}
{%- if client.server.key is defined %}
keyfile: {{ client.config.key }}
- {%- endif %}
\ No newline at end of file
+ {%- endif %}