Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kerberos auth #126

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pydruid/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""The main config file for pydruid

All configuration in this file can be overridden by providing a druid_config
in your PYTHONPATH as there is a ``from druid_config import *``
at the end of this file.
"""

import imp
import os
import sys

REQUESTS_AUTH = None

CONFIG_PATH_ENV_VAR = 'DRUID_CONFIG_PATH'

try:
if CONFIG_PATH_ENV_VAR in os.environ:
# Explicitly import config module that is not in pythonpath; useful
# for case where app is being executed via pex.
print('Loaded your LOCAL configuration at [{}]'.format(
os.environ[CONFIG_PATH_ENV_VAR]))
module = sys.modules[__name__]
override_conf = imp.load_source(
'druid_config',
os.environ[CONFIG_PATH_ENV_VAR])
for key in dir(override_conf):
if key.isupper():
setattr(module, key, getattr(override_conf, key))
else:
from druid_config import * # noqa
import druid_config
print('Loaded your LOCAL configuration at [{}]'.format(
druid_config.__file__))
except ImportError:
pass
4 changes: 3 additions & 1 deletion pydruid/db/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import requests

from pydruid.db import exceptions
from pydruid.config import REQUESTS_AUTH


class Type(object):
Expand Down Expand Up @@ -260,7 +261,8 @@ def _stream_query(self, query):

headers = {'Content-Type': 'application/json'}
payload = {'query': query}
r = requests.post(self.url, stream=True, headers=headers, json=payload)
r = requests.post(self.url, stream=True, headers=headers, json=payload,
auth=REQUESTS_AUTH)
if r.encoding is None:
r.encoding = 'utf-8'

Expand Down