From f2159472da63d21d52ca310d6a83f522010b75ef Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sun, 9 Feb 2020 13:41:41 +0200 Subject: [PATCH] Fix: encode/decode bytestring for base64. (#4624) * Fix: encode/decode bytestring for base64. * Apply b64encode fix to HiveHttp --- redash/query_runner/databricks.py | 4 ++-- redash/query_runner/hive_ds.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/redash/query_runner/databricks.py b/redash/query_runner/databricks.py index 4756581c20..3b137abb60 100644 --- a/redash/query_runner/databricks.py +++ b/redash/query_runner/databricks.py @@ -48,8 +48,8 @@ def _get_connection(self): transport = THttpClient.THttpClient(http_uri) password = self.configuration.get("http_password", "") - auth = base64.b64encode("token:" + password) - transport.setCustomHeaders({"Authorization": "Basic " + auth}) + auth = base64.b64encode(b"token:" + password.encode("ascii")) + transport.setCustomHeaders({"Authorization": "Basic " + auth.decode()}) connection = hive.connect(thrift_transport=transport) return connection diff --git a/redash/query_runner/hive_ds.py b/redash/query_runner/hive_ds.py index f1cc9a7ff2..626f8051cd 100644 --- a/redash/query_runner/hive_ds.py +++ b/redash/query_runner/hive_ds.py @@ -223,8 +223,8 @@ def _get_connection(self): username = self.configuration.get("username", "") password = self.configuration.get("http_password", "") if username or password: - auth = base64.b64encode(username + ":" + password) - transport.setCustomHeaders({"Authorization": "Basic " + auth}) + auth = base64.b64encode(username.encode("ascii") + b":" + password.encode("ascii")) + transport.setCustomHeaders({"Authorization": "Basic " + auth.decode()}) # create connection connection = hive.connect(thrift_transport=transport)