Skip to content

Commit

Permalink
Replace PyKerberos dependency with python-gssapi
Browse files Browse the repository at this point in the history
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%
*********************************************************************
  • Loading branch information
svmhdvn committed Apr 19, 2024
1 parent d2d7ae0 commit cf964bc
Show file tree
Hide file tree
Showing 14 changed files with 707 additions and 658 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.py[cod]
venv

# C extensions
*.so
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WSGI-Kerberos
WSGI-Kerberos is `WSGI`_ Middleware which implements `Kerberos`_ authentication.
It makes it easy to add Kerberos authentication to any WSGI application.

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

You can install the requirements from PyPI with ``easy_install`` or ``pip`` or
download them by hand.
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt

This file was deleted.

8 changes: 5 additions & 3 deletions example/example_application.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import logging
from wsgi_kerberos import KerberosAuthMiddleware
from wsgiref.simple_server import make_server

from wsgi_kerberos import KerberosAuthMiddleware


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


Expand Down
104 changes: 104 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "wsgi-kerberos"
dynamic = ["version"]
description = "Kerberos authentication support in WSGI Middleware"
readme = "README.rst"
requires-python = ">=3.8"
license = "BSD-3-Clause"
authors = [
{ name="Michael Komitee", email="mkomitee@gmail.com" },
]
maintainers = [
{ name="Vitaly Shupak", email="vitaly.shupak@deshaw.com" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"gssapi",
]

[project.urls]
Documentation = "https://github.com/unknown/wsgi-kerberos#readme"
Issues = "https://github.com/deshaw/wsgi-kerberos/issues"
Homepage = "https://github.com/deshaw/wsgi-kerberos"

[tool.hatch.version]
path = "src/wsgi_kerberos/__about__.py"

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"k5test",
"requests",
"requests-gssapi",
"wsgi-intercept",
]

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
]
cov = [
"test-cov",
"cov-report",
]

[[tool.hatch.envs.all.matrix]]
python = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]

[tool.hatch.envs.types]
dependencies = [
"mypy>=1.0.0",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/wsgi_kerberos tests}"

[tool.coverage.run]
source_pkgs = ["wsgi_kerberos", "tests"]
branch = true
parallel = true
omit = [
"src/wsgi_kerberos/__about__.py",
]

[tool.coverage.paths]
wsgi_kerberos = ["src/wsgi_kerberos", "*/wsgi-kerberos/src/wsgi_kerberos"]
tests = ["tests", "*/wsgi-kerberos/tests"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

4 changes: 4 additions & 0 deletions src/wsgi_kerberos/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2013-2020 D. E. Shaw & Co., L.P.
#
# SPDX-License-Identifier: BSD-3-Clause
__version__ = "1.1.0"
10 changes: 10 additions & 0 deletions src/wsgi_kerberos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: Copyright 2013-2020 D. E. Shaw & Co., L.P.
#
# SPDX-License-Identifier: BSD-3-Clause

from wsgi_kerberos.middleware import _DEFAULT_READ_MAX, KerberosAuthMiddleware

__all__ = [
'KerberosAuthMiddleware',
'_DEFAULT_READ_MAX'
]
Loading

0 comments on commit cf964bc

Please sign in to comment.