dj-jwt-auth 1.5.10__tar.gz → 1.5.11__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.5.10 → dj-jwt-auth-1.5.11}/PKG-INFO +1 -1
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/dj_jwt_auth.egg-info/PKG-INFO +1 -1
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/user.py +5 -2
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/setup.cfg +1 -1
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/tests/models.py +1 -1
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/tests/test.py +10 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/MANIFEST.in +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/README.md +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/dj_jwt_auth.egg-info/SOURCES.txt +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/dj_jwt_auth.egg-info/dependency_links.txt +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/dj_jwt_auth.egg-info/requires.txt +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/dj_jwt_auth.egg-info/top_level.txt +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/__init__.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/config.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/exceptions.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/middleware.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/pkce.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/roles.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/settings.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/templates/admin/login.html +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/templates/django-jwt-index.html +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/urls.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/utils.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/django_jwt/views.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/pyproject.toml +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/setup.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/tests/__init__.py +0 -0
- {dj-jwt-auth-1.5.10 → dj-jwt-auth-1.5.11}/tests/urls.py +0 -0
|
@@ -43,7 +43,7 @@ class UserHandler:
|
|
|
43
43
|
"""Collect user data from KeyCloak"""
|
|
44
44
|
|
|
45
45
|
user_data = oidc_handler.get_user_info(self.access_token)
|
|
46
|
-
log.info(f"User data: {user_data}
|
|
46
|
+
log.info(f"[OIDC] User data: {user_data}")
|
|
47
47
|
self.kwargs["email"] = user_data["email"].lower()
|
|
48
48
|
self.kwargs.update(mapper(user_data))
|
|
49
49
|
|
|
@@ -85,7 +85,7 @@ class UserHandler:
|
|
|
85
85
|
is_modified = user_modified_at < self.modified_at
|
|
86
86
|
|
|
87
87
|
log.info(
|
|
88
|
-
f"User modified at: {user_modified_at}, "
|
|
88
|
+
f"[OIDC] User modified at: {user_modified_at}, "
|
|
89
89
|
f"modified_at: {self.modified_at}, "
|
|
90
90
|
f"is_modified: {is_modified}, "
|
|
91
91
|
f"email: {user.email}",
|
|
@@ -113,6 +113,9 @@ class UserHandler:
|
|
|
113
113
|
return self._get_by_email()
|
|
114
114
|
except model.DoesNotExist:
|
|
115
115
|
return self._create_new_user()
|
|
116
|
+
except model.MultipleObjectsReturned:
|
|
117
|
+
log.error(f"[OIDC] Multiple users found by {settings.OIDC_USER_UID}: {self.kwargs[settings.OIDC_USER_UID]}")
|
|
118
|
+
return self._get_by_email()
|
|
116
119
|
|
|
117
120
|
|
|
118
121
|
class RoleHandler:
|
|
@@ -4,5 +4,5 @@ from django.utils import timezone
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class User(AbstractUser):
|
|
7
|
-
kc_id = models.CharField(max_length=255,
|
|
7
|
+
kc_id = models.CharField(max_length=255, null=True, blank=True)
|
|
8
8
|
modified_timestamp = models.DateTimeField(auto_now=False, default=timezone.now)
|
|
@@ -112,6 +112,16 @@ class OIDCHandlerTest(TestCase):
|
|
|
112
112
|
# fields are updated if they are changed in KeyCloak
|
|
113
113
|
self.assertUserWithPayload()
|
|
114
114
|
|
|
115
|
+
def test_exists_multiple_kc_id(self, *_):
|
|
116
|
+
"""User exists in database by email"""
|
|
117
|
+
user = User.objects.create(email="example@bk.com", kc_id="123")
|
|
118
|
+
User.objects.create(email="example@gmail.com", kc_id="123", username="other")
|
|
119
|
+
self.middleware.process_request(self.request)
|
|
120
|
+
self.assertEqual(self.request.user, user)
|
|
121
|
+
|
|
122
|
+
# fields are updated if they are changed in KeyCloak
|
|
123
|
+
self.assertUserWithPayload()
|
|
124
|
+
|
|
115
125
|
def test_exists_email_differeent_kc_id_user(self, *_):
|
|
116
126
|
"""User exists in database by email but different kc_id"""
|
|
117
127
|
user = User.objects.create(email="example@bk.com", kc_id="123")
|
|
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
|
|
File without changes
|