Skip to content

Commit cf964bc

Browse files
committed
Replace PyKerberos dependency with python-gssapi
This patch comprises the following changes: * Replace 'kerberos' with 'gssapi' * Modernize packaging by adding a hatch-based pyproject.toml * Remove lingering python2 support * Use a real kerberos realm for running tests (i.e. remove mock calls) Future TODO: * Support all GSSAPI backends generically and remove Kerberos references * Add many more tests to cover all remaining branches and cases Current test coverage report: ********************************************************************* cmd [1] | coverage run -m pytest tests ===== test session starts ===== platform linux -- Python 3.12.3, pytest-8.1.1, pluggy-1.4.0 rootdir: ~/src/wsgi-kerberos configfile: pyproject.toml collected 12 items tests/test_wsgi_kerberos.py ............ [100%] ===== 12 passed in 3.13s ===== cmd [2] | - coverage combine Combined data file .coverage.15380.XqZVXpnx cmd [3] | coverage report Name Stmts Miss Branch BrPart Cover ------------------------------------------------------------------- src/wsgi_kerberos/__init__.py 2 0 0 0 100% src/wsgi_kerberos/middleware.py 111 21 34 6 80% tests/__init__.py 0 0 0 0 100% tests/test_wsgi_kerberos.py 170 0 48 0 100% ------------------------------------------------------------------- TOTAL 283 21 82 6 92% *********************************************************************
1 parent d2d7ae0 commit cf964bc

14 files changed

Lines changed: 707 additions & 658 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.py[cod]
2+
venv
23

34
# C extensions
45
*.so

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ WSGI-Kerberos
44
WSGI-Kerberos is `WSGI`_ Middleware which implements `Kerberos`_ authentication.
55
It makes it easy to add Kerberos authentication to any WSGI application.
66

7-
Its only dependency is `python-kerberos`_ and it's been tested up to version 1.3.0
7+
Its only dependency is `gssapi`_ and it's been tested with v1.8.3 onwards.
88

99
You can install the requirements from PyPI with ``easy_install`` or ``pip`` or
1010
download them by hand.

docs/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/example_application.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
2+
23
import logging
3-
from wsgi_kerberos import KerberosAuthMiddleware
44
from wsgiref.simple_server import make_server
55

6+
from wsgi_kerberos import KerberosAuthMiddleware
7+
68

79
def example(environ, start_response):
810
user = environ.get('REMOTE_USER', 'ANONYMOUS')
911
start_response('200 OK', [('Content-Type', 'text/plain')])
10-
data = "Hello {}".format(user)
12+
data = f"Hello {user}"
1113
return [data.encode()]
1214

1315

pyproject.toml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "wsgi-kerberos"
7+
dynamic = ["version"]
8+
description = "Kerberos authentication support in WSGI Middleware"
9+
readme = "README.rst"
10+
requires-python = ">=3.8"
11+
license = "BSD-3-Clause"
12+
authors = [
13+
{ name="Michael Komitee", email="mkomitee@gmail.com" },
14+
]
15+
maintainers = [
16+
{ name="Vitaly Shupak", email="vitaly.shupak@deshaw.com" },
17+
]
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Environment :: Web Environment",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: BSD License",
23+
"Operating System :: OS Independent",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 3.8",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: Implementation :: CPython",
31+
"Programming Language :: Python :: Implementation :: PyPy",
32+
"Topic :: Internet :: WWW/HTTP",
33+
"Topic :: Internet :: WWW/HTTP :: WSGI",
34+
"Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
35+
"Topic :: Software Development :: Libraries :: Python Modules",
36+
]
37+
dependencies = [
38+
"gssapi",
39+
]
40+
41+
[project.urls]
42+
Documentation = "https://github.com/unknown/wsgi-kerberos#readme"
43+
Issues = "https://github.com/deshaw/wsgi-kerberos/issues"
44+
Homepage = "https://github.com/deshaw/wsgi-kerberos"
45+
46+
[tool.hatch.version]
47+
path = "src/wsgi_kerberos/__about__.py"
48+
49+
[tool.hatch.envs.default]
50+
dependencies = [
51+
"coverage[toml]>=6.5",
52+
"pytest",
53+
"k5test",
54+
"requests",
55+
"requests-gssapi",
56+
"wsgi-intercept",
57+
]
58+
59+
[tool.hatch.envs.default.scripts]
60+
test = "pytest {args:tests}"
61+
test-cov = "coverage run -m pytest {args:tests}"
62+
cov-report = [
63+
"- coverage combine",
64+
"coverage report",
65+
]
66+
cov = [
67+
"test-cov",
68+
"cov-report",
69+
]
70+
71+
[[tool.hatch.envs.all.matrix]]
72+
python = [
73+
"3.8",
74+
"3.9",
75+
"3.10",
76+
"3.11",
77+
"3.12",
78+
]
79+
80+
[tool.hatch.envs.types]
81+
dependencies = [
82+
"mypy>=1.0.0",
83+
]
84+
[tool.hatch.envs.types.scripts]
85+
check = "mypy --install-types --non-interactive {args:src/wsgi_kerberos tests}"
86+
87+
[tool.coverage.run]
88+
source_pkgs = ["wsgi_kerberos", "tests"]
89+
branch = true
90+
parallel = true
91+
omit = [
92+
"src/wsgi_kerberos/__about__.py",
93+
]
94+
95+
[tool.coverage.paths]
96+
wsgi_kerberos = ["src/wsgi_kerberos", "*/wsgi-kerberos/src/wsgi_kerberos"]
97+
tests = ["tests", "*/wsgi-kerberos/tests"]
98+
99+
[tool.coverage.report]
100+
exclude_lines = [
101+
"no cov",
102+
"if __name__ == .__main__.:",
103+
"if TYPE_CHECKING:",
104+
]

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/wsgi_kerberos/__about__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-FileCopyrightText: Copyright 2013-2020 D. E. Shaw & Co., L.P.
2+
#
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
__version__ = "1.1.0"

src/wsgi_kerberos/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-FileCopyrightText: Copyright 2013-2020 D. E. Shaw & Co., L.P.
2+
#
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
from wsgi_kerberos.middleware import _DEFAULT_READ_MAX, KerberosAuthMiddleware
6+
7+
__all__ = [
8+
'KerberosAuthMiddleware',
9+
'_DEFAULT_READ_MAX'
10+
]

0 commit comments

Comments
 (0)