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

Warn rather than raise on opportunistic auth failure. #31

Merged
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
23 changes: 15 additions & 8 deletions requests_gssapi/gssapi_.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,21 @@ def __call__(self, request):
# by the 401 handler
host = urlparse(request.url).hostname

auth_header = self.generate_request_header(None, host,
is_preemptive=True)

log.debug(
"HTTPSPNEGOAuth: Preemptive Authorization header: {0}"
.format(auth_header))

request.headers['Authorization'] = auth_header
try:
auth_header = self.generate_request_header(None, host,
is_preemptive=True)
log.debug(
"HTTPSPNEGOAuth: Preemptive Authorization header: {0}"
.format(auth_header))
except SPNEGOExchangeError as exc:
log.warning(
"HTTPSPNEGOAuth: Opportunistic auth failed with %s ->"
" sending request without adding Authorization header."
" Will try again if it results in a 401.",
exc)
else:
log.debug("HTTPSPNEGOAuth: Added opportunistic auth header")
request.headers['Authorization'] = auth_header

request.register_hook('response', self.handle_response)
try:
Expand Down