From 1ebf485fc0e09ab98b331a219c9909f6afccff19 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sun, 9 Feb 2020 11:25:01 +0200 Subject: [PATCH 1/2] Fix: encode/decode bytestring for base64. --- redash/query_runner/databricks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 From db0f6e1bd1cd32240b0610432b4ecced06260177 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sun, 9 Feb 2020 11:49:38 +0200 Subject: [PATCH 2/2] Apply b64encode fix to HiveHttp --- redash/query_runner/hive_ds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)