Skip to content

Commit d8d0b34

Browse files
committed
Fix dispatcher2 basic auth encoding
1 parent 6d1627f commit d8d0b34

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

webapp/app/controllers/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,9 @@ def sendsms_to_uuids_task(uuid_list, msg):
430430

431431
@app.task(name="queue_in_dispatcher2")
432432
def queue_in_dispatcher2(data, url=config['dispatcher2_queue_url'], ctype="json", params={}):
433-
coded = base64.b64encode(
434-
"%s:%s" % (config['dispatcher2_username'], config['dispatcher2_password']))
433+
credentials = "%s:%s" % (
434+
config['dispatcher2_username'], config['dispatcher2_password'])
435+
coded = base64.b64encode(credentials.encode("utf-8")).decode("ascii")
435436
if 'xml' in ctype:
436437
ct = 'text/xml'
437438
elif 'json' in ctype:
@@ -678,4 +679,3 @@ def sync_facility_task(uids, pg_conn_params,):
678679

679680
conn.commit()
680681
conn.close()
681-

webapp/app/tools/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ def parse_message(msg, kw=""):
234234

235235

236236
def post_request_to_dispatcher2(data, url=config['dispatcher2_queue_url'], ctype="xml", params={}):
237-
coded = base64.b64encode(
238-
"%s:%s" % (config['dispatcher2_username'], config['dispatcher2_password']))
237+
credentials = "%s:%s" % (
238+
config['dispatcher2_username'], config['dispatcher2_password'])
239+
coded = base64.b64encode(credentials.encode("utf-8")).decode("ascii")
239240
if ctype == 'xml':
240241
ct = 'text/xml'
241242
elif ctype == 'json':
@@ -387,4 +388,3 @@ def fields_clause_from_param(fields_param, allowed_fields):
387388

388389
def where_clause_from_conditions(conditions):
389390
return "WHERE " + " AND ".join(conditions) if conditions else ""
390-

0 commit comments

Comments
 (0)