@@ -3,7 +3,15 @@ requests GSSAPI authentication library
3
3
4
4
Requests is an HTTP library, written in Python, for human beings. This library
5
5
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:
7
15
8
16
9
17
.. code-block :: python
@@ -77,8 +85,8 @@ authentication, you can do that as well:
77
85
>> > r = requests.get(" http://example.org" , auth = gssapi_auth)
78
86
...
79
87
80
- Preemptive Authentication
81
- -------------------------
88
+ Opportunistic Authentication
89
+ ----------------------------
82
90
83
91
``HTTPSPNEGOAuth `` can be forced to preemptively initiate the GSSAPI
84
92
exchange and present a token on the initial request (and all
@@ -87,13 +95,13 @@ subsequent). By default, authentication only occurs after a
87
95
is received from the origin server. This can cause mutual authentication
88
96
failures for hosts that use a persistent connection (eg, Windows/WinRM), as
89
97
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 ``:
91
99
92
100
.. code-block :: python
93
101
94
102
>> > import requests
95
103
>> > 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 )
97
105
>> > r = requests.get(" https://windows.example.org/wsman" , auth = gssapi_auth)
98
106
...
99
107
@@ -103,31 +111,30 @@ Hostname Override
103
111
If communicating with a host whose DNS name doesn't match its
104
112
hostname (eg, behind a content switch or load balancer),
105
113
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 ``) :
107
115
108
116
.. code-block :: python
109
117
110
118
>> > import requests
111
119
>> > from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
112
- >> > gssapi_auth = HTTPSPNEGOAuth(hostname_override = " internalhost.local" )
120
+ >> > gssapi_auth = HTTPSPNEGOAuth(target_name = " internalhost.local" )
113
121
>> > r = requests.get(" https://externalhost.example.org/" , auth = gssapi_auth)
114
122
...
115
123
116
124
Explicit Principal
117
125
------------------
118
126
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.
125
130
126
131
.. code-block :: python
127
132
133
+ >> > import gssapi
128
134
>> > import requests
129
135
>> > 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)
131
138
>> > r = requests.get(" http://example.org" , auth = gssapi_auth)
132
139
...
133
140
0 commit comments