druid-io / pydruid

A Python connector for Druid
Other
506 stars 194 forks source link

Add kerberos auth #126

Open Dubrzr opened 6 years ago

Dubrzr commented 6 years ago

Fixing issue https://github.com/druid-io/pydruid/issues/125

Only implemented for the requests call done (need to do it for urllib calls also).

Dubrzr commented 6 years ago

What about urllib calls? Would you replace them with requests calls?

mistercrunch commented 6 years ago

Ha! this config.py looks oddly familiar :) That looks good to me.

Now we probably want to sprinkle this across the app, for all http calls. And yes we should systematically use requests for all http requests.

There might be a way to start a requests session somehow and set the auth for the session. I have done no research though, that's just intuition...

nishantmonu51 commented 6 years ago

It seems that it might be easier to just use urllib instead of requests for kerberos auth across the app.

In the config.py you would do something like and then in the app wherever you use urllib, it can use the configured security.

try:
    # python3
    import urllib.request as urllib_request
except ImportError:
    # python2
    import urllib2 as urllib_request
cookieProcessor = urllib_request.HTTPCookieProcessor()
authencationHandler = urllib_kerberos.HTTPKerberosAuthHandler()
opener = urllib_request.build_opener(cookieProcessor, authencationHandler)
urllib_request.install_opener(opener)

On a side note i also filed and issue for replacing requests library usage with urllib here as it is a blocker for us - https://github.com/druid-io/pydruid/issues/128