Skip to content

Commit 488658f

Browse files
functions for JWT validation 🛡️
1 parent 7bbb2ac commit 488658f

36 files changed

Lines changed: 1089 additions & 69 deletions

.github/workflows/build.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ jobs:
1818
build:
1919
runs-on: ubuntu-18.04
2020
strategy:
21+
fail-fast: false
2122
matrix:
22-
python-version: [3.6, 3.7, 3.8, 3.9]
23+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
2324

2425
steps:
2526
- uses: actions/checkout@v1
@@ -47,9 +48,20 @@ jobs:
4748
run: |
4849
pip install -U --no-index --find-links=deps deps/*
4950
51+
- name: Run linters
52+
run: |
53+
echo "Running linters - if build fails here, please be patient! Feel free to ask for assistance."
54+
55+
flake8 $PROJECT_NAME
56+
flake8 tests
57+
isort --check-only $PROJECT_NAME 2>&1
58+
isort --check-only tests 2>&1
59+
black --check $PROJECT_NAME 2>&1
60+
black --check tests 2>&1
61+
5062
- name: Run tests
5163
run: |
52-
flake8 && pytest --doctest-modules --junitxml=junit/pytest-results-${{ matrix.python-version }}.xml --cov=$PROJECT_NAME --cov-report=xml tests/
64+
pytest --doctest-modules --junitxml=junit/pytest-results-${{ matrix.python-version }}.xml --cov=$PROJECT_NAME --cov-report=xml tests/
5365
5466
- name: Upload pytest test results
5567
uses: actions/upload-artifact@master

.isort.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[settings]
2+
profile = black
3+
multi_line_output = 3

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.0.8] - 2021-05-??
8+
## [0.0.8] - 2021-10-31 :shield:
9+
- Adds classes to handle `JWT`s validation, but only for `RSA` keys
910
- Fixes issue (wrong arrangement in test) #5
11+
- Includes `Python 3.10` in the CI/CD matrix
12+
- Enforces `black` and `isort` in the CI pipeline
1013

1114
## [0.0.7] - 2021-01-31 :grapes:
1215
- Corrects a bug in the `Policy` class (#2)

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ in any kind of Python application.
1212
pip install guardpost
1313
```
1414

15+
To install with support for `JSON Web Tokens (JWTs)` validation:
16+
17+
```
18+
pip install guardpost[jwt]
19+
```
20+
1521
This library is freely inspired by [authorization in ASP.NET
1622
Core](https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-2.2);
1723
although its implementation is extremely different.

guardpost/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from .authentication import User, Identity
1+
from .authentication import Identity, User
22
from .authorization import (
3+
AuthorizationError,
4+
BaseRequirement,
35
Policy,
46
PolicyNotFoundError,
5-
AuthorizationError,
67
UnauthorizedError,
7-
BaseRequirement,
88
)

guardpost/asynchronous/authentication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from abc import abstractmethod
22
from typing import Any, Optional, Sequence
3+
34
from guardpost.authentication import (
4-
Identity,
55
BaseAuthenticationHandler,
66
BaseAuthenticationStrategy,
7+
Identity,
78
)
89

910

guardpost/asynchronous/authorization.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
from functools import wraps
21
from abc import abstractmethod
2+
from functools import wraps
33
from typing import Dict, Optional
4+
45
from guardpost.authentication import Identity
56
from guardpost.authorization import (
7+
AuthorizationContext,
8+
BaseAuthorizationStrategy,
9+
BaseRequirement,
610
Policy,
711
PolicyNotFoundError,
8-
AuthorizationContext,
912
UnauthorizedError,
10-
BaseRequirement,
11-
BaseAuthorizationStrategy,
1213
)
1314
from guardpost.funchelper import args_to_dict_getter
1415
from guardpost.synchronous.authorization import Requirement as SyncRequirement

guardpost/authorization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from abc import ABC
2-
from typing import Sequence, Optional, List, Dict, Callable
2+
from typing import Callable, Dict, List, Optional, Sequence
3+
34
from guardpost.authentication import Identity
45

56

guardpost/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class AuthException(Exception):
2+
"""Base class for all exception risen by the library."""
3+
4+
5+
class UnsupportedFeatureError(AuthException):
6+
"""Exception risen for unsupported features."""

guardpost/funchelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import Tuple, Dict, Callable
21
from inspect import Signature
2+
from typing import Callable, Dict, Tuple
33

44

55
def args_to_dict_getter(method: Callable):

0 commit comments

Comments
 (0)