dj-jwt-auth 1.9.4__tar.gz → 1.9.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/PKG-INFO +3 -6
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/README.md +2 -5
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/dj_jwt_auth.egg-info/PKG-INFO +3 -6
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/config.py +6 -8
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/settings.py +0 -4
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/views.py +3 -2
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/setup.cfg +1 -1
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/MANIFEST.in +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/dj_jwt_auth.egg-info/SOURCES.txt +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/dj_jwt_auth.egg-info/dependency_links.txt +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/dj_jwt_auth.egg-info/requires.txt +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/dj_jwt_auth.egg-info/top_level.txt +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/__init__.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/exceptions.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/middleware.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/pkce.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/roles.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/templates/admin/login.html +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/templates/django-jwt-index.html +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/urls.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/user.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/django_jwt/utils.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/pyproject.toml +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/setup.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/tests/__init__.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/tests/models.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/tests/test.py +0 -0
- {dj_jwt_auth-1.9.4 → dj_jwt_auth-1.9.5}/tests/urls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dj-jwt-auth
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.5
|
|
4
4
|
Summary: A Django package for JSON Web Token validation and verification. Using PyJWT.
|
|
5
5
|
Home-page: https://www.example.com/
|
|
6
6
|
Author: Konstantin Seleznev
|
|
@@ -102,12 +102,9 @@ OR
|
|
|
102
102
|
These functions should accept two arguments: user and request.
|
|
103
103
|
|
|
104
104
|
### Admin panel integration:
|
|
105
|
-
To integrate admin panel with OIDC, add
|
|
106
|
-
- OIDC_ADMIN_ISSUER - for admin-panel access through OIDC. By default will be used 'ES256' from OIDC_CONFIG_ROUTES. Example:
|
|
107
|
-
```
|
|
108
|
-
OIDC_ADMIN_ISSUER = "https://keyCloak/realms/h/.well-known/openid-configuration"
|
|
109
|
-
```
|
|
105
|
+
To integrate admin panel with OIDC, add OIDC_ADMIN_CLIENT_ID to settings. Example:
|
|
110
106
|
- OIDC_ADMIN_CLIENT_ID - by default "complete-anatomy"
|
|
107
|
+
By default will be used 'ES256' from OIDC_CONFIG_ROUTES as Issuer.
|
|
111
108
|
To mapping roles to admin panel permissions, use OIDC_ADMIN_ROLES. Example:
|
|
112
109
|
|
|
113
110
|
```python
|
|
@@ -73,12 +73,9 @@ OR
|
|
|
73
73
|
These functions should accept two arguments: user and request.
|
|
74
74
|
|
|
75
75
|
### Admin panel integration:
|
|
76
|
-
To integrate admin panel with OIDC, add
|
|
77
|
-
- OIDC_ADMIN_ISSUER - for admin-panel access through OIDC. By default will be used 'ES256' from OIDC_CONFIG_ROUTES. Example:
|
|
78
|
-
```
|
|
79
|
-
OIDC_ADMIN_ISSUER = "https://keyCloak/realms/h/.well-known/openid-configuration"
|
|
80
|
-
```
|
|
76
|
+
To integrate admin panel with OIDC, add OIDC_ADMIN_CLIENT_ID to settings. Example:
|
|
81
77
|
- OIDC_ADMIN_CLIENT_ID - by default "complete-anatomy"
|
|
78
|
+
By default will be used 'ES256' from OIDC_CONFIG_ROUTES as Issuer.
|
|
82
79
|
To mapping roles to admin panel permissions, use OIDC_ADMIN_ROLES. Example:
|
|
83
80
|
|
|
84
81
|
```python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dj-jwt-auth
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.5
|
|
4
4
|
Summary: A Django package for JSON Web Token validation and verification. Using PyJWT.
|
|
5
5
|
Home-page: https://www.example.com/
|
|
6
6
|
Author: Konstantin Seleznev
|
|
@@ -102,12 +102,9 @@ OR
|
|
|
102
102
|
These functions should accept two arguments: user and request.
|
|
103
103
|
|
|
104
104
|
### Admin panel integration:
|
|
105
|
-
To integrate admin panel with OIDC, add
|
|
106
|
-
- OIDC_ADMIN_ISSUER - for admin-panel access through OIDC. By default will be used 'ES256' from OIDC_CONFIG_ROUTES. Example:
|
|
107
|
-
```
|
|
108
|
-
OIDC_ADMIN_ISSUER = "https://keyCloak/realms/h/.well-known/openid-configuration"
|
|
109
|
-
```
|
|
105
|
+
To integrate admin panel with OIDC, add OIDC_ADMIN_CLIENT_ID to settings. Example:
|
|
110
106
|
- OIDC_ADMIN_CLIENT_ID - by default "complete-anatomy"
|
|
107
|
+
By default will be used 'ES256' from OIDC_CONFIG_ROUTES as Issuer.
|
|
111
108
|
To mapping roles to admin panel permissions, use OIDC_ADMIN_ROLES. Example:
|
|
112
109
|
|
|
113
110
|
```python
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
from enum import StrEnum
|
|
2
3
|
from functools import cache
|
|
3
4
|
from urllib.parse import urljoin
|
|
4
5
|
|
|
@@ -9,6 +10,11 @@ from django_jwt import settings
|
|
|
9
10
|
from django_jwt.exceptions import AlgorithmNotSupportedException, ConfigException
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
class SupportedAlgorithms(StrEnum):
|
|
14
|
+
ES256 = "ES256"
|
|
15
|
+
RS256 = "RS256"
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
def ensure_well_known(url: str) -> str:
|
|
13
19
|
if url.endswith(".well-known/openid-configuration"):
|
|
14
20
|
return url
|
|
@@ -42,13 +48,5 @@ class Config:
|
|
|
42
48
|
algorithm = RSAAlgorithm if key_data["kty"] == "RSA" else ECAlgorithm
|
|
43
49
|
return algorithm.from_jwk(json.dumps(key_data))
|
|
44
50
|
|
|
45
|
-
@cache
|
|
46
|
-
def admin(self) -> dict:
|
|
47
|
-
if settings.OIDC_ADMIN_ISSUER:
|
|
48
|
-
response = requests.get(ensure_well_known(settings.OIDC_ADMIN_ISSUER))
|
|
49
|
-
response.raise_for_status()
|
|
50
|
-
return response.json()
|
|
51
|
-
raise ConfigException("OIDC_ADMIN_ISSUER is not set")
|
|
52
|
-
|
|
53
51
|
|
|
54
52
|
config = Config()
|
|
@@ -38,7 +38,6 @@ OIDC_USER_ON_UPDATE = getattr(
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
OIDC_CONFIG_ROUTES = getattr(settings, "OIDC_CONFIG_ROUTES", {})
|
|
41
|
-
OIDC_ADMIN_ISSUER = getattr(settings, "OIDC_ADMIN_ISSUER", None)
|
|
42
41
|
OIDC_ADMIN_CLIENT_ID = getattr(settings, "OIDC_ADMIN_CLIENT_ID", "gme-completeanatomy-admin")
|
|
43
42
|
OIDC_ADMIN_SCOPE = getattr(settings, "OIDC_ADMIN_SCOPE", "openid")
|
|
44
43
|
OIDC_ADMIN_ROLES = getattr(settings, "OIDC_ADMIN_ROLES", [])
|
|
@@ -49,9 +48,6 @@ OIDC_AUTHORIZATION_BACKEND = getattr(
|
|
|
49
48
|
"django.contrib.auth.backends.ModelBackend",
|
|
50
49
|
)
|
|
51
50
|
|
|
52
|
-
if not OIDC_ADMIN_ISSUER:
|
|
53
|
-
OIDC_ADMIN_ISSUER = OIDC_CONFIG_ROUTES.get("ES256", None)
|
|
54
|
-
|
|
55
51
|
for role in OIDC_ADMIN_ROLES:
|
|
56
52
|
assert isinstance(role, ROLE), f"Role must be a namedtuple, got {type(role)}"
|
|
57
53
|
|
|
@@ -11,7 +11,7 @@ from django.views import View
|
|
|
11
11
|
from requests.exceptions import HTTPError
|
|
12
12
|
|
|
13
13
|
from django_jwt import settings as jwt_settings
|
|
14
|
-
from django_jwt.config import config
|
|
14
|
+
from django_jwt.config import SupportedAlgorithms, config
|
|
15
15
|
from django_jwt.exceptions import BadRequestException, ConfigException
|
|
16
16
|
from django_jwt.pkce import PKCESecret
|
|
17
17
|
from django_jwt.user import UserHandler, role_handler
|
|
@@ -44,11 +44,12 @@ class InitiateView(View):
|
|
|
44
44
|
client_id = None
|
|
45
45
|
scope = "openid"
|
|
46
46
|
params = {}
|
|
47
|
+
algorithm = SupportedAlgorithms.ES256
|
|
47
48
|
|
|
48
49
|
def get(self, request):
|
|
49
50
|
pkce_secret = PKCESecret()
|
|
50
51
|
redirect_uri = request.build_absolute_uri(reverse(self.callback_view_name))
|
|
51
|
-
authorization_endpoint = config.
|
|
52
|
+
authorization_endpoint = config.cfg(self.algorithm).get("authorization_endpoint")
|
|
52
53
|
state = base64.urlsafe_b64encode(get_random_string().encode()).decode()
|
|
53
54
|
self.params = {
|
|
54
55
|
"client_id": self.client_id,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|