Skip to content
Merged
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
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
History
=======

1.0.0: 2017-12-14
-----------------

- Fork project to requests-gssapi
- Replace pykerberos with python-gssapi
- Add HTTPSPNEGOAuth interface. HTTPKerberosAuth is retained as a shim, but
bump the major version anyway for clarity.

0.11.0: 2016-11-02
------------------

Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ applicable). However, an explicit credential can be in instead, if desired.
>>> import gssapi
>>> import requests
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
>>> creds = gssapi.Credentials(name=gssapi.Name("user@REALM"), usage="initiate")
>>> name = gssapi.Name("user@REALM", gssapi.NameType.hostbased_service)
>>> creds = gssapi.Credentials(name=name, usage="initiate")
>>> gssapi_auth = HTTPSPNEGOAuth(creds=creds)
>>> r = requests.get("http://example.org", auth=gssapi_auth)
...
Expand Down
2 changes: 1 addition & 1 deletion requests_gssapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

__all__ = ('HTTPSPNEGOAuth', 'HTTPKerberosAuth', 'MutualAuthenticationError',
'REQUIRED', 'OPTIONAL', 'DISABLED')
__version__ = '0.11.0'
__version__ = '1.0.0'
6 changes: 4 additions & 2 deletions requests_gssapi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def generate_request_header(self, response, host, is_preemptive=False):
try:
if self.principal is not None:
gss_stage = "acquiring credentials"
name = gssapi.Name(self.principal)
name = gssapi.Name(
self.principal, gssapi.NameType.hostbased_service)
self.creds = gssapi.Credentials(name=name, usage="initiate")

# contexts still need to be stored by host, but hostname_override
Expand All @@ -59,7 +60,8 @@ def generate_request_header(self, response, host, is_preemptive=False):
kerb_host = self.hostname_override

kerb_spn = "{0}@{1}".format(self.service, kerb_host)
self.target_name = gssapi.Name(kerb_spn)
self.target_name = gssapi.Name(
kerb_spn, gssapi.NameType.hostbased_service)

return HTTPSPNEGOAuth.generate_request_header(self, response,
host, is_preemptive)
Expand Down
9 changes: 6 additions & 3 deletions requests_gssapi/gssapi_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
import logging

from base64 import b64encode, b64decode

import gssapi

from requests.auth import AuthBase
Expand Down Expand Up @@ -73,7 +75,7 @@ def _negotiate_value(response):
if authreq:
match_obj = regex.search(authreq)
if match_obj:
return match_obj.group(1)
return b64decode(match_obj.group(1))

return None

Expand Down Expand Up @@ -132,7 +134,8 @@ def generate_request_header(self, response, host, is_preemptive=False):
if '@' not in self.target_name:
self.target_name = "%s@%s" % (self.target_name, host)

self.target_name = gssapi.Name(self.target_name)
self.target_name = gssapi.Name(
self.target_name, gssapi.NameType.hostbased_service)
self.context[host] = gssapi.SecurityContext(
usage="initiate", flags=gssflags, name=self.target_name,
creds=self.creds)
Expand All @@ -144,7 +147,7 @@ def generate_request_header(self, response, host, is_preemptive=False):
gss_response = self.context[host].step(
_negotiate_value(response))

return "Negotiate {0}".format(gss_response)
return "Negotiate {0}".format(b64encode(gss_response).decode())

except gssapi.exceptions.GSSError as error:
msg = error.gen_message()
Expand Down
Loading