You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V1Meta does not handle authenication error properly with HTTPNTLMAuthHandler #25
It passed in response.info method when it should be issue response.info()
Once this was fixed and no longer raised an exception, it expose an additional bug where it would recursively call the http_error_401 due to self.parent.error recalling this method. So to fix this, I found I needed to apply the following solution to raise the appropriate HTTP Error for 404.
class CustomHTTPNtlmAuthHandler(HTTPNtlmAuthHandler):
""" A version of HTTPNtlmAuthHandler that handles errors (better).
The default version doesn't use `self.parent.open` in it's
error handler, and completely bypasses the normal `OpenerDirector`
call chain, most importantly `HTTPErrorProcessor.http_response`,
which normally raises an error for 'bad' http status codes..
"""
def http_error_401(self, req, fp, code, msg, hdrs):
response = HTTPNtlmAuthHandler.http_error_401(self, req, fp, code, msg, hdrs)
if not (200 <= response.code < 300):
- response = self.parent.error(
- 'http', req, response, response.code, response.msg,
- response.info)
+ if response.code == 401:
+ raise HTTPError(req.get_full_url(), response.code, response.msg, response.info(), fp)
+ else:
+ response = self.parent.error(
+ 'http', req, response, response.code, response.msg,
+ response.info())
return response
Activity
aarcro commentedon Nov 24, 2015
An additional issue here. 'ntlm' not in auth_header_value.lower(), then response is None, and .code is an attribute error.
Merge pull request versionone#25 from mtalexan/memoization-bug-fix