Skip to content

Commit b30a2a8

Browse files
Merge branch 'dev/1.0.3' of github.com:Neoteroi/GuardPost into dev/1.0.3
2 parents 4faa4b1 + 1f68bc5 commit b30a2a8

9 files changed

Lines changed: 378 additions & 55 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: [3.8, 3.9, "3.10", "3.11"]
23+
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
2424

2525
steps:
2626
- uses: actions/checkout@v1
@@ -81,18 +81,18 @@ jobs:
8181
8282
- name: Install distribution dependencies
8383
run: pip install --upgrade build
84-
if: matrix.python-version == 3.10
84+
if: matrix.python-version == 3.12
8585

8686
- name: Create distribution package
8787
run: python -m build
88-
if: matrix.python-version == 3.10
88+
if: matrix.python-version == 3.12
8989

9090
- name: Upload distribution package
9191
uses: actions/upload-artifact@master
9292
with:
9393
name: dist
9494
path: dist
95-
if: matrix.python-version == 3.10
95+
if: matrix.python-version == 3.12
9696

9797
publish:
9898
runs-on: ubuntu-latest
@@ -105,10 +105,10 @@ jobs:
105105
name: dist
106106
path: dist
107107

108-
- name: Use Python 3.11
108+
- name: Use Python 3.12
109109
uses: actions/setup-python@v1
110110
with:
111-
python-version: '3.11'
111+
python-version: "3.12"
112112

113113
- name: Install dependencies
114114
run: |

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
(`SymmetricJWTValidator` and `AsymmetricJWTValidator`).
1414
- Add support to call the `authorize` method with an optional set of roles,
1515
treated as sufficient roles to succeed authorization.
16+
- Add Python `3.12` and `3.13` to the build matrix.
17+
- Remove Python `3.8` from the build matrix.
18+
- Improve `pyproject.toml`.
1619

1720
## [1.0.2] - 2023-06-16 :corn:
1821

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Roberto Prevato
3+
Copyright (c) 2019-present Roberto Prevato roberto.prevato@gmail.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

guardpost/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.2"
1+
__version__ = "1.0.3"

guardpost/jwts/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class JWTValidatorProtocol(Protocol):
3939
async def validate_jwt(self, access_token: str) -> Dict[str, Any]: ...
4040

4141

42-
class AbstractJWTValidator:
43-
"""Base class for JWT validators with common functionality"""
42+
class BaseJWTValidator:
43+
"""Base class for JWT validators with common functionality."""
4444

4545
def __init__(
4646
self,
@@ -55,7 +55,11 @@ def __init__(
5555
self.logger = get_logger()
5656

5757

58-
class AsymmetricJWTValidator(AbstractJWTValidator):
58+
class AsymmetricJWTValidator(BaseJWTValidator):
59+
"""
60+
A JWTValidator that can validate JWTs signed using asymmetric encryption.
61+
"""
62+
5963
def __init__(
6064
self,
6165
*,
@@ -196,7 +200,7 @@ async def validate_jwt(self, access_token: str) -> Dict[str, Any]:
196200
raise InvalidAccessToken()
197201

198202

199-
class SymmetricJWTValidator(AbstractJWTValidator):
203+
class SymmetricJWTValidator(BaseJWTValidator):
200204
def __init__(
201205
self,
202206
*,
@@ -262,7 +266,7 @@ async def validate_jwt(self, access_token: str) -> Dict[str, Any]:
262266
raise InvalidAccessToken()
263267

264268

265-
class CompositeJWTValidator(AbstractJWTValidator):
269+
class CompositeJWTValidator(BaseJWTValidator):
266270
def __init__(self, validators: List[JWTValidatorProtocol]) -> None:
267271
"""
268272
Creates a composite validator that tries multiple validation strategies.

pyproject.toml

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,36 @@ build-backend = "hatchling.build"
55
[project]
66
name = "guardpost"
77
dynamic = ["version"]
8-
authors = [
9-
{ name = "Roberto Prevato", email = "roberto.prevato@gmail.com" },
10-
]
8+
authors = [{ name = "Roberto Prevato", email = "roberto.prevato@gmail.com" }]
9+
license = "MIT"
10+
license-files = ["LICENSE"]
1111
description = "Framework to handle authentication and authorization."
1212
readme = "README.md"
1313
requires-python = ">=3.7"
1414
classifiers = [
15-
"Development Status :: 5 - Production/Stable",
16-
"License :: OSI Approved :: MIT License",
17-
"Programming Language :: Python :: 3",
18-
"Programming Language :: Python :: 3.7",
19-
"Programming Language :: Python :: 3.8",
20-
"Programming Language :: Python :: 3.9",
21-
"Programming Language :: Python :: 3.10",
22-
"Programming Language :: Python :: 3.11",
23-
"Operating System :: OS Independent",
15+
"Development Status :: 5 - Production/Stable",
16+
"License :: OSI Approved :: MIT License",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"Operating System :: OS Independent",
2424
]
2525
keywords = ["authentication", "authorization", "identity", "claims", "strategy"]
26-
dependencies = [
27-
"rodi>=2.0.0",
28-
"typing_extensions; python_version < '3.8'",
29-
]
26+
dependencies = ["rodi>=2.0.0", "typing_extensions; python_version < '3.8'"]
3027

3128
[project.optional-dependencies]
32-
jwt = [
33-
"PyJWT",
34-
"cryptography",
35-
]
29+
jwt = ["PyJWT", "cryptography"]
3630

3731
[tool.hatch.build.targets.sdist]
38-
exclude = [
39-
"/.github",
40-
"/docs",
41-
"/examples",
42-
"/deps",
43-
"/styles",
44-
"/tests",
45-
"mkdocs-plugins.code-workspace",
46-
"Makefile",
47-
"CODE_OF_CONDUCT.md",
48-
".isort.cfg",
49-
".gitignore",
50-
".flake8",
51-
"junit",
52-
"guardpost.code-workspace",
53-
"requirements.txt",
54-
"examples-summary.py"
32+
include = [
33+
"guardpost/",
34+
"README.md",
35+
"LICENSE*",
36+
"CHANGELOG*",
37+
"pyproject.toml",
5538
]
5639

5740
[tool.hatch.version]

tests/serverfixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from multiprocessing import Process
44
from time import sleep
55

6-
import pkg_resources
6+
from importlib.resources import files
77
import pytest
88
from flask import Flask
99

@@ -17,7 +17,7 @@
1717

1818

1919
def get_file_path(file_name, folder_name: str = "res") -> str:
20-
return pkg_resources.resource_filename(__name__, f"./{folder_name}/{file_name}")
20+
return str(files(__package__) / folder_name / file_name)
2121

2222

2323
def get_test_jwks_dict():

tests/test_examples.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import glob
22
import importlib
33
import sys
4+
from pathlib import Path
45

56
import pytest
67

7-
examples = [file for file in glob.glob("./examples/*.py")]
8+
examples = [
9+
file for file in glob.glob("./examples/*.py") if not file.endswith("__init__.py")
10+
]
811

912

1013
sys.path.append("./examples")
1114

1215

1316
@pytest.mark.parametrize("file_path", examples)
1417
def test_example(file_path: str):
15-
module_name = file_path.replace("./examples/", "").replace(".py", "")
16-
# assertions are in imported
18+
module_name = Path(file_path).stem
19+
# assertions are in the imported code
1720
importlib.import_module(module_name)

0 commit comments

Comments
 (0)