Skip to content

Commit 3bd6b1f

Browse files
committed
Update all meta data to reflect httpx
1 parent fa91144 commit 3bd6b1f

File tree

8 files changed

+133
-95
lines changed

8 files changed

+133
-95
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
env/
44
build/
55
dist/
6-
requests_gssapi.egg-info/
6+
httpx_gssapi.egg-info/
7+
venv*/
8+
.idea/
79

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Michael Komitee
22
Jose Castro Leon
33
David Pursehouse
44
Robbie Harwood
5+
Roger Aiudi

HISTORY.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
History
22
=======
33

4+
?.0.0: 2020-03-1?
5+
-----------------
6+
7+
- Fork project to httpx-gssapi
8+
- Replace all requests handling to support HTTPX
9+
10+
411
1.2.0: 2020-02-18
512
-----------------
613

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ISC License
33
Copyright (c) 2012-2017 Kenneth Reitz
44
Copyright (c) 2017 the python-requests-gssapi contributors
55
Copyright (c) 2017 Red Hat, Inc.
6+
Copyright (c) 2020 Roger Aiudi
67

78
Permission to use, copy, modify and/or distribute this software for any
89
purpose with or without fee is hereby granted, provided that the above

README.rst

+41-48
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
requests GSSAPI authentication library
2-
===============================================
1+
HTTPX GSSAPI authentication library
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
Requests is an HTTP library, written in Python, for human beings. This library
5-
adds optional GSSAPI authentication support and supports mutual
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.
4+
`HTTPX <https://github.com/encode/httpx>`_ is a full featured Python HTTP library with both sync and async APIs
5+
designed to be a next generation HTTP client for Python. This library is a port
6+
of `Requests GSSAPI <https://github.com/pythongssapi/requests-gssapi>`_ to HTTPX which adds optional GSSAPI authentication support and
7+
supports mutual authentication.
138

149
Basic GET usage:
1510

16-
1711
.. code-block:: python
1812
19-
>>> import requests
20-
>>> from requests_gssapi import HTTPSPNEGOAuth
21-
>>> r = requests.get("http://example.org", auth=HTTPSPNEGOAuth())
22-
...
13+
>>> import httpx
14+
>>> from httpx_gssapi import HTTPSPNEGOAuth
15+
>>> r = httpx.get("http://example.org", auth=HTTPSPNEGOAuth())
2316
24-
The entire ``requests.api`` should be supported.
17+
Both the sync and async HTTPX APIs should be fully supported.
2518

2619
Setup
2720
-----
@@ -49,7 +42,7 @@ Mutual Authentication
4942

5043
Mutual authentication is a poorly-named feature of the GSSAPI which doesn't
5144
provide any additional security benefit to most possible uses of
52-
requests_gssapi. Practically speaking, in most mechanism implementations
45+
httpx_gssapi. Practically speaking, in most mechanism implementations
5346
(including krb5), it requires another round-trip between the client and server
5447
during the authentication handshake. Many clients and servers do not properly
5548
handle the authentication handshake taking more than one round-trip. If you
@@ -73,14 +66,14 @@ DISABLED
7366

7467
By default, there's no need to explicitly disable mutual authentication.
7568
However, for compatability with older versions of request_gssapi or
76-
requests_kerberos, you can explicitly request it not be attempted:
69+
httpx_kerberos, you can explicitly request it not be attempted:
7770

7871
.. code-block:: python
7972
80-
>>> import requests
81-
>>> from requests_gssapi import HTTPSPNEGOAuth, DISABLED
73+
>>> import httpx
74+
>>> from httpx_gssapi import HTTPSPNEGOAuth, DISABLED
8275
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=DISABLED)
83-
>>> r = requests.get("https://example.org", auth=gssapi_auth)
76+
>>> r = httpx.get("https://example.org", auth=gssapi_auth)
8477
...
8578
8679
REQUIRED
@@ -89,7 +82,7 @@ REQUIRED
8982
This was historically the default, but no longer is. If requested,
9083
``HTTPSPNEGOAuth`` will require mutual authentication from the server, and if
9184
a server emits a non-error response which cannot be authenticated, a
92-
``requests_gssapi.errors.MutualAuthenticationError`` will be raised. (See
85+
``httpx_gssapi.errors.MutualAuthenticationError`` will be raised. (See
9386
above for what this means.) If a server emits an error which cannot be
9487
authenticated, it will be returned to the user but with its contents and
9588
headers stripped. If the response content is more important than the need for
@@ -98,27 +91,27 @@ can be suppressed by setting ``sanitize_mutual_error_response=False``:
9891

9992
.. code-block:: python
10093
101-
>>> import requests
102-
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
94+
>>> import httpx
95+
>>> from httpx_gssapi import HTTPSPNEGOAuth, REQUIRED
10396
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=REQUIRED, sanitize_mutual_error_response=False)
104-
>>> r = requests.get("https://windows.example.org/wsman", auth=gssapi_auth)
97+
>>> r = httpx.get("https://windows.example.org/wsman", auth=gssapi_auth)
10598
...
10699
107100
OPTIONAL
108101
^^^^^^^^
109102

110-
This will cause ``requests_gssapi`` to attempt mutual authentication if the
103+
This will cause ``httpx_gssapi`` to attempt mutual authentication if the
111104
server advertises that it supports it, and cause a failure if authentication
112105
fails, but not if the server does not support it at all. This is probably not
113106
what you want: link tampering will either cause hard failures, or silently
114107
cause it to not happen at all. It is retained for compatability.
115108

116109
.. code-block:: python
117110
118-
>>> import requests
119-
>>> from requests_gssapi import HTTPSPNEGOAuth, OPTIONAL
111+
>>> import httpx
112+
>>> from httpx_gssapi import HTTPSPNEGOAuth, OPTIONAL
120113
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=OPTIONAL)
121-
>>> r = requests.get("https://example.org", auth=gssapi_auth)
114+
>>> r = httpx.get("https://example.org", auth=gssapi_auth)
122115
...
123116
124117
Opportunistic Authentication
@@ -135,10 +128,10 @@ behavior can be altered by setting ``opportunistic_auth=True``:
135128

136129
.. code-block:: python
137130
138-
>>> import requests
139-
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
131+
>>> import httpx
132+
>>> from httpx_gssapi import HTTPSPNEGOAuth, REQUIRED
140133
>>> gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=REQUIRED, opportunistic_auth=True)
141-
>>> r = requests.get("https://windows.example.org/wsman", auth=gssapi_auth)
134+
>>> r = httpx.get("https://windows.example.org/wsman", auth=gssapi_auth)
142135
...
143136
144137
Hostname Override
@@ -151,10 +144,10 @@ passing in a custom name (string or ``gssapi.Name``):
151144

152145
.. code-block:: python
153146
154-
>>> import requests
155-
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
147+
>>> import httpx
148+
>>> from httpx_gssapi import HTTPSPNEGOAuth, REQUIRED
156149
>>> gssapi_auth = HTTPSPNEGOAuth(target_name="internalhost.local")
157-
>>> r = requests.get("https://externalhost.example.org/", auth=gssapi_auth)
150+
>>> r = httpx.get("https://externalhost.example.org/", auth=gssapi_auth)
158151
...
159152
160153
Explicit Principal
@@ -167,12 +160,12 @@ applicable). However, an explicit credential can be in instead, if desired.
167160
.. code-block:: python
168161
169162
>>> import gssapi
170-
>>> import requests
171-
>>> from requests_gssapi import HTTPSPNEGOAuth, REQUIRED
163+
>>> import httpx
164+
>>> from httpx_gssapi import HTTPSPNEGOAuth, REQUIRED
172165
>>> name = gssapi.Name("user@REALM", gssapi.NameType.hostbased_service)
173166
>>> creds = gssapi.Credentials(name=name, usage="initiate")
174167
>>> gssapi_auth = HTTPSPNEGOAuth(creds=creds)
175-
>>> r = requests.get("http://example.org", auth=gssapi_auth)
168+
>>> r = httpx.get("http://example.org", auth=gssapi_auth)
176169
...
177170
178171
Explicit Mechanism
@@ -186,28 +179,28 @@ without interference. It is expected to be an instance of ``gssapi.mechs.Mechani
186179
.. code-block:: python
187180
188181
>>> import gssapi
189-
>>> import requests
190-
>>> from requests_gssapi import HTTPSPNEGOAuth
182+
>>> import httpx
183+
>>> from httpx_gssapi import HTTPSPNEGOAuth
191184
>>> try:
192185
... spnego = gssapi,mechs.Mechanism.from_sasl_name("SPNEGO")
193186
... except AttributeError:
194187
... spnego = gssapi.OID.from_int_seq("1.3.6.1.5.5.2")
195188
>>> gssapi_auth = HTTPSPNEGOAuth(mech=spnego)
196-
>>> r = requests.get("http://example.org", auth=gssapi_auth)
189+
>>> r = httpx.get("http://example.org", auth=gssapi_auth)
197190
...
198191
199192
Delegation
200193
----------
201194

202-
``requests_gssapi`` supports credential delegation (``GSS_C_DELEG_FLAG``).
195+
``httpx_gssapi`` supports credential delegation (``GSS_C_DELEG_FLAG``).
203196
To enable delegation of credentials to a server that requests delegation, pass
204197
``delegate=True`` to ``HTTPSPNEGOAuth``:
205198

206199
.. code-block:: python
207200
208-
>>> import requests
209-
>>> from requests_gssapi import HTTPSPNEGOAuth
210-
>>> r = requests.get("http://example.org", auth=HTTPSPNEGOAuth(delegate=True))
201+
>>> import httpx
202+
>>> from httpx_gssapi import HTTPSPNEGOAuth
203+
>>> r = httpx.get("http://example.org", auth=HTTPSPNEGOAuth(delegate=True))
211204
...
212205
213206
Be careful to only allow delegation to servers you trust as they will be able
@@ -218,8 +211,8 @@ Logging
218211

219212
This library makes extensive use of Python's logging facilities.
220213

221-
Log messages are logged to the ``requests_gssapi`` and
222-
``requests_gssapi.gssapi`` named loggers.
214+
Log messages are logged to the ``httpx_gssapi`` and
215+
``httpx_gssapi.gssapi`` named loggers.
223216

224217
If you are having difficulty we suggest you configure logging. Issues with the
225218
underlying GSSAPI libraries will be made apparent. Additionally, copious debug

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
requests>=1.1.0
1+
httpx
22
gssapi
3+
pytest

setup.cfg

+65-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
1-
[wheel]
2-
universal = 1
1+
[metadata]
2+
name = httpx-gssapi
3+
description = A GSSAPI authentication handler for Python's HTTPX
4+
author = Ian Cordasco, Cory Benfield, Michael Komitee, Robbie Harwood, Roger Aiudi
5+
author_email = [email protected]
6+
url = https://github.com/pythongssapi/httpx-gssapi
7+
license = MIT
8+
classifiers =
9+
Development Status :: 5 - Production/Stable
10+
Intended Audience :: Developers
11+
License :: OSI Approved :: ISC License (ISCL)
12+
Programming Language :: Python :: 3.6
13+
Programming Language :: Python :: 3.7
14+
Programming Language :: Python :: 3.8
15+
Topic :: Software Development :: Libraries :: Python Modules
16+
keywords =
17+
httpx
18+
gssapi
19+
kerberos
20+
21+
[options]
22+
include_package_data = True
23+
python_requires = >=3.6
24+
packages = httpx_gssapi
25+
tests_require = pytest
26+
install_requires =
27+
httpx
28+
gssapi
29+
30+
[options.package_data]
31+
* =
32+
LICENSE
33+
AUTHORS
34+
35+
[coverage:run]
36+
source = .
37+
include = httpx_gssapi/*,test_httpx_gssapi.py
38+
39+
[coverage:html]
40+
directory = coverage/
41+
42+
[coverage:report]
43+
exclude_lines =
44+
pragma: no cover
45+
if TYPE_CHECKING:
46+
if __name__ == .__main__.:
47+
pass
48+
include = httpx_gssapi/*,test_httpx_gssapi.py
49+
50+
[build_sphinx]
51+
source-dir = doc/
52+
build-dir = doc/build/
53+
54+
[flake8]
55+
max-line-length = 80
56+
filename = httpx_gssapi/**.py
57+
exclude = tests,build,dist,venv,.tox,*.egg*,coverage,doc
58+
59+
[versioneer]
60+
VCS = git
61+
style = pep440
62+
versionfile_source = httpx_gssapi/_version.py
63+
versionfile_build = httpx_gssapi/_version.py
64+
tag_prefix = v
65+
parentdir_prefix = httpx_gssapi-

setup.py

+13-43
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,29 @@
11
#!/usr/bin/env python
2-
# coding: utf-8
3-
import os
42
import re
3+
from pathlib import Path
54
from setuptools import setup
65

7-
path = os.path.dirname(__file__)
8-
desc_fd = os.path.join(path, 'README.rst')
9-
hist_fd = os.path.join(path, 'HISTORY.rst')
6+
path = Path(__file__).parent
7+
readme = path / 'README.rst'
8+
history = path / 'HISTORY.rst'
109

11-
long_desc = ''
12-
short_desc = 'A GSSAPI authentication handler for python-requests'
13-
14-
if os.path.isfile(desc_fd):
15-
with open(desc_fd) as fd:
16-
long_desc = fd.read()
17-
18-
if os.path.isfile(hist_fd):
19-
with open(hist_fd) as fd:
20-
long_desc = '\n\n'.join([long_desc, fd.read()])
10+
long_desc = readme.read_text() if readme.exists() else ''
11+
if history.exists():
12+
long_desc = '\n\n'.join([long_desc, history.read_text()])
2113

2214

2315
def get_version():
24-
"""
25-
Simple function to extract the current version using regular expressions.
26-
"""
16+
"""Get current version using regex to avoid import."""
2717
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
28-
with open('requests_gssapi/__init__.py') as fd:
29-
matches = list(filter(lambda x: x, map(reg.match, fd)))
30-
31-
if not matches:
32-
raise RuntimeError(
33-
'Could not find the version information for requests_gssapi'
34-
)
18+
with (path / 'httpx_gssapi' / '__init__.py').open() as fd:
19+
match = next(filter(None, map(reg.match, fd)), None)
3520

36-
return matches[0].group(1)
21+
if match is None:
22+
raise RuntimeError('Could not find the version for httpx_gssapi')
23+
return match.group(1)
3724

3825

3926
setup(
40-
name='requests-gssapi',
41-
description=short_desc,
4227
long_description=long_desc,
43-
author='Ian Cordasco, Cory Benfield, Michael Komitee, Robbie Harwood',
44-
author_email='[email protected]',
45-
url='https://github.com/pythongssapi/requests-gssapi',
46-
packages=['requests_gssapi'],
47-
package_data={'': ['LICENSE', 'AUTHORS']},
48-
include_package_data=True,
4928
version=get_version(),
50-
install_requires=[
51-
'requests>=1.1.0',
52-
'gssapi',
53-
],
54-
test_suite='test_requests_gssapi',
55-
tests_require=['mock'],
56-
classifiers=[
57-
"License :: OSI Approved :: ISC License (ISCL)"
58-
],
5929
)

0 commit comments

Comments
 (0)