Open Dubrzr opened 6 years ago
What about urllib calls? Would you replace them with requests calls?
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...
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
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).