Skip to content

Commit

Permalink
Support authentication for URL data source (re #330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short committed Feb 7, 2018
1 parent fcbd52d commit ee12602
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions redash/query_runner/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def configuration_schema(cls):
'type': 'string',
'title': 'URL base path'
},
'username': {
'type': 'string',
'title': 'HTTP username'
},
'password': {
'type': 'string',
'title': 'HTTP password'
},
"doc_url": {
"type": "string",
"title": "Documentation URL",
Expand Down Expand Up @@ -51,8 +59,11 @@ def run_query(self, query, user):
base_url = ""

url = base_url + query

response = requests.get(url)
auth = None
if self.configuration.get("username"):
auth = (self.configuration['username'],
self.configuration.get('password', ''))
response = requests.get(url, auth=auth)
response.raise_for_status()
json_data = response.content.strip()

Expand Down

0 comments on commit ee12602

Please sign in to comment.