dj-jwt-auth 1.3.2__tar.gz → 1.4.1__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.3.2 → dj-jwt-auth-1.4.1}/PKG-INFO +2 -1
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/README.md +1 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/dj_jwt_auth.egg-info/PKG-INFO +2 -1
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/settings.py +1 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/user.py +2 -2
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/setup.cfg +1 -1
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/tests/test.py +3 -5
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/dj_jwt_auth.egg-info/SOURCES.txt +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/dj_jwt_auth.egg-info/dependency_links.txt +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/dj_jwt_auth.egg-info/requires.txt +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/dj_jwt_auth.egg-info/top_level.txt +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/__init__.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/config.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/exceptions.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/middleware.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/pkce.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/roles.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/urls.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/utils.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/django_jwt/views.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/pyproject.toml +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/setup.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/tests/__init__.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/tests/models.py +0 -0
- {dj-jwt-auth-1.3.2 → dj-jwt-auth-1.4.1}/tests/urls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dj-jwt-auth
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
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
|
|
@@ -65,6 +65,7 @@ User retated variables:
|
|
|
65
65
|
- OIDC_USER_MODIFIED_FIELD - user model field to store last modified date, by default `modified_timestamp`
|
|
66
66
|
- OIDC_TOKEN_MODIFIED_FIELD - access token field to store last modified date, by default `updated_at`
|
|
67
67
|
- OIDC_USER_UID - User model" unique identifier, by default `kc_id`
|
|
68
|
+
- OIDC_TOKEN_USER_UID - access token field to store user UID, by default `sub`
|
|
68
69
|
- OIDC_USER_MAPPING - mapping between JWT claims and user model fields, by default:
|
|
69
70
|
```
|
|
70
71
|
OIDC_USER_MAPPING = {
|
|
@@ -41,6 +41,7 @@ User retated variables:
|
|
|
41
41
|
- OIDC_USER_MODIFIED_FIELD - user model field to store last modified date, by default `modified_timestamp`
|
|
42
42
|
- OIDC_TOKEN_MODIFIED_FIELD - access token field to store last modified date, by default `updated_at`
|
|
43
43
|
- OIDC_USER_UID - User model" unique identifier, by default `kc_id`
|
|
44
|
+
- OIDC_TOKEN_USER_UID - access token field to store user UID, by default `sub`
|
|
44
45
|
- OIDC_USER_MAPPING - mapping between JWT claims and user model fields, by default:
|
|
45
46
|
```
|
|
46
47
|
OIDC_USER_MAPPING = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dj-jwt-auth
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
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
|
|
@@ -65,6 +65,7 @@ User retated variables:
|
|
|
65
65
|
- OIDC_USER_MODIFIED_FIELD - user model field to store last modified date, by default `modified_timestamp`
|
|
66
66
|
- OIDC_TOKEN_MODIFIED_FIELD - access token field to store last modified date, by default `updated_at`
|
|
67
67
|
- OIDC_USER_UID - User model" unique identifier, by default `kc_id`
|
|
68
|
+
- OIDC_TOKEN_USER_UID - access token field to store user UID, by default `sub`
|
|
68
69
|
- OIDC_USER_MAPPING - mapping between JWT claims and user model fields, by default:
|
|
69
70
|
```
|
|
70
71
|
OIDC_USER_MAPPING = {
|
|
@@ -8,6 +8,7 @@ OIDC_CONFIG_URL = getattr(settings, "OIDC_CONFIG_URL", None)
|
|
|
8
8
|
OIDC_USER_UPDATE = getattr(settings, "OIDC_USER_UPDATE", True)
|
|
9
9
|
OIDC_USER_MODIFIED_FIELD = getattr(settings, "OIDC_USER_MODIFIED_FIELD", "modified_timestamp")
|
|
10
10
|
OIDC_TOKEN_MODIFIED_FIELD = getattr(settings, "OIDC_TOKEN_MODIFIED_FIELD", "updated_at")
|
|
11
|
+
OIDC_TOKEN_USER_UID = getattr(settings, "OIDC_TOKEN_USER_UID", "sub")
|
|
11
12
|
OIDC_USER_UID = getattr(settings, "OIDC_USER_UID", "kc_id")
|
|
12
13
|
OIDC_USER_MAPPING = getattr(
|
|
13
14
|
settings,
|
|
@@ -21,9 +21,8 @@ class UserHandler:
|
|
|
21
21
|
|
|
22
22
|
def __init__(self, payload: dict, request: HttpRequest, access_token: str):
|
|
23
23
|
# payload of access token without user info
|
|
24
|
-
# auth0_id should be available if auth0 added in Client Scopes in KeyCloak admin
|
|
25
24
|
self.kwargs = settings.OIDC_USER_DEFAULTS.copy()
|
|
26
|
-
self.kwargs[settings.OIDC_USER_UID] = payload.
|
|
25
|
+
self.kwargs[settings.OIDC_USER_UID] = payload[settings.OIDC_TOKEN_USER_UID]
|
|
27
26
|
|
|
28
27
|
modified_at = payload.get(settings.OIDC_TOKEN_MODIFIED_FIELD, None)
|
|
29
28
|
if modified_at and isinstance(modified_at, int):
|
|
@@ -42,6 +41,7 @@ class UserHandler:
|
|
|
42
41
|
self.kwargs.update(
|
|
43
42
|
{ca_key: user_data[kc_key] for kc_key, ca_key in settings.OIDC_USER_MAPPING.items() if kc_key in user_data}
|
|
44
43
|
)
|
|
44
|
+
log.info(f"User data: {self.kwargs}, access_token: {self.access_token}")
|
|
45
45
|
|
|
46
46
|
def _update_user(self, user):
|
|
47
47
|
"""Update user fields if they are changed"""
|
|
@@ -13,13 +13,11 @@ from django_jwt.user import role_handler
|
|
|
13
13
|
from django_jwt.roles import ROLE
|
|
14
14
|
|
|
15
15
|
access_token_payload = {
|
|
16
|
-
"sub": "
|
|
17
|
-
"auth0_id": "1234",
|
|
16
|
+
"sub": "1234",
|
|
18
17
|
"updated_at": 2687276498,
|
|
19
18
|
}
|
|
20
19
|
user_info_payload = {
|
|
21
|
-
"sub": "
|
|
22
|
-
"auth0_id": "1234",
|
|
20
|
+
"sub": "1234",
|
|
23
21
|
"email": "example@bk.com",
|
|
24
22
|
"name": "UserName",
|
|
25
23
|
"given_name": "1st name",
|
|
@@ -51,7 +49,7 @@ class OIDCHandlerTest(TestCase):
|
|
|
51
49
|
self.assertEqual(self.request.user.last_name, user_info_payload["family_name"])
|
|
52
50
|
self.assertEqual(self.request.user.username, user_info_payload["name"])
|
|
53
51
|
self.assertEqual(self.request.user.email, user_info_payload["email"])
|
|
54
|
-
self.assertEqual(self.request.user.kc_id, user_info_payload["
|
|
52
|
+
self.assertEqual(self.request.user.kc_id, user_info_payload["sub"])
|
|
55
53
|
|
|
56
54
|
def test_keycloak_new_user(self, *_):
|
|
57
55
|
"""User is created if it doesn't exist in database"""
|
|
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
|