From 3494e21cf44a592f64ecf234aaaab31229d2b477 Mon Sep 17 00:00:00 2001 From: Jakdaw Date: Thu, 5 Dec 2019 07:27:59 +0000 Subject: [PATCH] Add user/pass authentication support for Druid (#4315) * Add support for configuring a Username/Password for the connection to Druid * Bump pydruid version for username/password support * Deal with missing/empty configuration parameters --- redash/query_runner/druid.py | 15 ++++++++++++--- requirements_all_ds.txt | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/redash/query_runner/druid.py b/redash/query_runner/druid.py index 17e55f4a67..bec254de32 100644 --- a/redash/query_runner/druid.py +++ b/redash/query_runner/druid.py @@ -34,10 +34,17 @@ def configuration_schema(cls): "scheme": { "type": "string", "default": "http" + }, + "user": { + "type": "string" + }, + "password": { + "type": "string" } }, - "order": ['scheme', 'host', 'port'], - "required": ['host'] + "order": ['scheme', 'host', 'port', 'user', 'password'], + "required": ['host'], + "secret": ['password'] } @classmethod @@ -48,7 +55,9 @@ def run_query(self, query, user): connection = connect(host=self.configuration['host'], port=self.configuration['port'], path='/druid/v2/sql/', - scheme=self.configuration['scheme']) + scheme=(self.configuration.get('scheme') or 'http'), + user=(self.configuration.get('user') or None), + password=(self.configuration.get('password') or None)) cursor = connection.cursor() diff --git a/requirements_all_ds.txt b/requirements_all_ds.txt index 25b29acdf2..35931b9ae5 100644 --- a/requirements_all_ds.txt +++ b/requirements_all_ds.txt @@ -24,7 +24,7 @@ PyAthena>=1.5.0 pymapd==0.16.0 qds-sdk>=1.9.6 ibm-db>=2.0.9 -pydruid==0.5.5 +pydruid==0.5.7 requests_aws_sign==0.1.5 snowflake-connector-python==2.0.3 phoenixdb==0.7