Skip to content

Commit 68bada2

Browse files
Update docs for deprecation changes and new features
Signed-off-by: Robbie Harwood <[email protected]>
1 parent 725e5f9 commit 68bada2

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

README.rst

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ requests GSSAPI authentication library
33

44
Requests is an HTTP library, written in Python, for human beings. This library
55
adds optional GSSAPI authentication support and supports mutual
6-
authentication. Basic GET usage:
6+
authentication.
7+
8+
It provides a fully backward-compatible shim for the old
9+
python-requests-kerberos library: simply replace ``import requests_kerberos``
10+
with ``import requests_gssapi``. A more powerful interface is provided by the
11+
HTTPSPNEGOAuth component, but this is of course not guaranteed to be
12+
compatible. Documentation below is written toward the new interface.
13+
14+
Basic GET usage:
715

816

917
.. code-block:: python
@@ -77,8 +85,8 @@ authentication, you can do that as well:
7785
>>> r = requests.get("http://example.org", auth=gssapi_auth)
7886
...
7987
80-
Preemptive Authentication
81-
-------------------------
88+
Opportunistic Authentication
89+
----------------------------
8290

8391
``HTTPSPNEGOAuth`` can be forced to preemptively initiate the GSSAPI
8492
exchange and present a token on the initial request (and all
@@ -87,13 +95,13 @@ subsequent). By default, authentication only occurs after a
8795
is received from the origin server. This can cause mutual authentication
8896
failures for hosts that use a persistent connection (eg, Windows/WinRM), as
8997
no GSSAPI challenges are sent after the initial auth handshake. This
90-
behavior can be altered by setting ``force_preemptive=True``:
98+
behavior can be altered by setting ``opportunistic_auth=True``:
9199

92100
.. code-block:: python
93101
94102
>>> import requests
95103
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
96-
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=REQUIRED, force_preemptive=True)
104+
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=REQUIRED, opportunistic_authentication=True)
97105
>>> r = requests.get("https://windows.example.org/wsman", auth=gssapi_auth)
98106
...
99107
@@ -103,31 +111,30 @@ Hostname Override
103111
If communicating with a host whose DNS name doesn't match its
104112
hostname (eg, behind a content switch or load balancer),
105113
the hostname used for the GSSAPI exchange can be overridden by
106-
setting the ``hostname_override`` arg:
114+
passing in a custom name (string or ``gssapi.Name``):
107115

108116
.. code-block:: python
109117
110118
>>> import requests
111119
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
112-
>>> gssapi_auth = HTTPSPNEGOAuth(hostname_override="internalhost.local")
120+
>>> gssapi_auth = HTTPSPNEGOAuth(target_name="internalhost.local")
113121
>>> r = requests.get("https://externalhost.example.org/", auth=gssapi_auth)
114122
...
115123
116124
Explicit Principal
117125
------------------
118126

119-
``HTTPSPNEGOAuth`` normally uses the default principal (ie, the user for
120-
whom you last ran ``kinit`` or ``kswitch``, or an SSO credential if
121-
applicable). However, an explicit principal can be specified, which will
122-
cause GSSAPI to look for a matching credential cache for the named user.
123-
This feature depends on OS support for collection-type credential caches.
124-
An explicit principal can be specified with the ``principal`` arg:
127+
``HTTPSPNEGOAuth`` normally uses the default principal (ie, the user for whom
128+
you last ran ``kinit`` or ``kswitch``, or an SSO credential if
129+
applicable). However, an explicit credential can be in instead, if desired.
125130

126131
.. code-block:: python
127132
133+
>>> import gssapi
128134
>>> import requests
129135
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
130-
>>> gssapi_auth = HTTPSPNEGOAuth(principal="user@REALM")
136+
>>> creds = gssapi.Credentials(name=gssapi.Name("user@REALM"), usage="initiate")
137+
>>> gssapi_auth = HTTPSPNEGOAuth(creds=creds)
131138
>>> r = requests.get("http://example.org", auth=gssapi_auth)
132139
...
133140

requests_gssapi/gssapi_.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,27 @@ def _negotiate_value(response):
7979

8080

8181
class HTTPSPNEGOAuth(AuthBase):
82-
"""Attaches HTTP GSSAPI Authentication to the given Request object."""
82+
"""Attaches HTTP GSSAPI Authentication to the given Request object.
83+
84+
`mutual_authentication` controls whether GSSAPI should attempt mutual
85+
authentication. It may be `REQUIRED` (default), `OPTIONAL`, or
86+
`DISABLED`.
87+
88+
`target_name` specifies the remote principal name. It may be either a
89+
GSSAPI name type or a string (default: "HTTP" at the DNS host).
90+
91+
`delegate` indicates whether we should attempt credential delegation.
92+
Default is `False`.
93+
94+
`opportunistic_auth` indicates whether we should assume the server will
95+
ask for Negotiation. Defaut is `False`.
96+
97+
`creds` is GSSAPI credentials (gssapi.Credentials) to use for negotiation.
98+
Default is `None`.
99+
100+
`sanitize_mutual_error_response` controls whether we should clean up
101+
server responses. See the `SanitizedResponse` class.
102+
"""
83103
def __init__(self, mutual_authentication=REQUIRED, target_name="HTTP",
84104
delegate=False, opportunistic_auth=False, creds=None,
85105
sanitize_mutual_error_response=True):

0 commit comments

Comments
 (0)