dj-jwt-auth 1.5.1__tar.gz → 1.5.2__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.
Files changed (25) hide show
  1. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/PKG-INFO +1 -1
  2. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/dj_jwt_auth.egg-info/PKG-INFO +1 -1
  3. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/urls.py +1 -1
  4. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/user.py +3 -4
  5. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/setup.cfg +1 -1
  6. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/tests/models.py +2 -1
  7. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/tests/test.py +26 -2
  8. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/README.md +0 -0
  9. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/dj_jwt_auth.egg-info/SOURCES.txt +0 -0
  10. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/dj_jwt_auth.egg-info/dependency_links.txt +0 -0
  11. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/dj_jwt_auth.egg-info/requires.txt +0 -0
  12. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/dj_jwt_auth.egg-info/top_level.txt +0 -0
  13. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/__init__.py +0 -0
  14. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/config.py +0 -0
  15. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/exceptions.py +0 -0
  16. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/middleware.py +0 -0
  17. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/pkce.py +0 -0
  18. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/roles.py +0 -0
  19. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/settings.py +0 -0
  20. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/utils.py +0 -0
  21. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/django_jwt/views.py +0 -0
  22. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/pyproject.toml +0 -0
  23. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/setup.py +0 -0
  24. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/tests/__init__.py +0 -0
  25. {dj-jwt-auth-1.5.1 → dj-jwt-auth-1.5.2}/tests/urls.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dj-jwt-auth
3
- Version: 1.5.1
3
+ Version: 1.5.2
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dj-jwt-auth
3
- Version: 1.5.1
3
+ Version: 1.5.2
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
@@ -4,6 +4,6 @@ from django_jwt import views
4
4
 
5
5
  urlpatterns = [
6
6
  path("oidc/callback/", views.ReceiveRedirectView.as_view(), name="receive_redirect_view"),
7
- path("oidc/logout/", views.silent_sso_check, name="silent_sso_check"),
7
+ path("oidc/logout/", views.LogoutView.as_view(), name="logout"),
8
8
  path("oidc/", views.StartOIDCAuthView.as_view(), name="start_oidc_auth"),
9
9
  ]
@@ -50,14 +50,13 @@ class UserHandler:
50
50
  def _update_user(self, user):
51
51
  """Update user fields if they are changed"""
52
52
 
53
- is_changed = False
54
53
  self._collect_user_data()
54
+ if hasattr(user, settings.OIDC_USER_MODIFIED_FIELD):
55
+ self.kwargs[settings.OIDC_USER_MODIFIED_FIELD] = self.modified_at
55
56
  for key, val in self.kwargs.items():
56
57
  if getattr(user, key) != val:
57
58
  setattr(user, key, val)
58
- is_changed = True
59
- if is_changed:
60
- user.save(update_fields=self.kwargs.keys())
59
+ user.save(update_fields=self.kwargs.keys())
61
60
 
62
61
  def _create_new_user(self) -> model:
63
62
  """Create new user if user is not found in database even by email."""
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = dj-jwt-auth
3
- version = 1.5.1
3
+ version = 1.5.2
4
4
  description = A Django package for JSON Web Token validation and verification. Using PyJWT.
5
5
  long_description = file: README.md
6
6
  url = https://www.example.com/
@@ -1,7 +1,8 @@
1
1
  from django.contrib.auth.models import AbstractUser
2
2
  from django.db import models
3
+ from django.utils import timezone
3
4
 
4
5
 
5
6
  class User(AbstractUser):
6
7
  kc_id = models.CharField(max_length=255, unique=True, null=True, blank=True)
7
- modified_timestamp = models.DateTimeField(auto_now=True)
8
+ modified_timestamp = models.DateTimeField(auto_now=False, default=timezone.now)
@@ -1,9 +1,11 @@
1
+ from datetime import datetime
1
2
  from http import HTTPStatus
2
3
  from unittest.mock import Mock, patch
3
4
 
5
+ import pytz
4
6
  from django.contrib.auth import get_user_model
5
7
  from django.contrib.auth.models import Group, Permission
6
- from django.test import TestCase, override_settings
8
+ from django.test import TestCase
7
9
  from django.urls import reverse
8
10
  from jwt.api_jwt import ExpiredSignatureError
9
11
 
@@ -12,6 +14,7 @@ from django_jwt.middleware import JWTAuthMiddleware
12
14
  from django_jwt.roles import ROLE
13
15
  from django_jwt.user import role_handler
14
16
 
17
+ utc = pytz.UTC
15
18
  access_token_payload = {
16
19
  "sub": "1234",
17
20
  "updated_at": 2687276498,
@@ -52,7 +55,7 @@ class OIDCHandlerTest(TestCase):
52
55
  def setUp(self):
53
56
  self.middleware = JWTAuthMiddleware(get_response=lambda x: x)
54
57
  self.request = Mock()
55
- self.request.META = {"HTTP_AUTHORIZATION": "Bearer 1234"}
58
+ self.request.META = {"HTTP_AUTHORIZATION": "Bearer Token"}
56
59
  settings.OIDC_USER_MAPPING = { # default mapping
57
60
  "given_name": "first_name",
58
61
  "family_name": "last_name",
@@ -166,6 +169,27 @@ class OIDCHandlerTest(TestCase):
166
169
  self.middleware.process_request(self.request)
167
170
  self.assertEqual(self.request.user.username, "override")
168
171
 
172
+ def test_updated_at(self, access_token, user_info):
173
+ """Check that
174
+ - the updated_at field saved correct
175
+ - don't call userdata if updated_at is not changed
176
+ """
177
+
178
+ updated_at = utc.localize(datetime.fromtimestamp(access_token_payload["updated_at"]))
179
+ user = User.objects.create(kc_id="1234", first_name="", last_name="", username="")
180
+
181
+ self.middleware.process_request(self.request)
182
+ self.assertEqual(self.request.user, user)
183
+ user.refresh_from_db()
184
+ self.assertEqual(user.modified_timestamp, updated_at)
185
+ self.assertEqual(user.username, user_info_payload["name"])
186
+ self.assertEqual(user_info.call_count, 1)
187
+
188
+ self.middleware.process_request(self.request)
189
+ user.refresh_from_db()
190
+ self.assertEqual(user.modified_timestamp, updated_at)
191
+ # self.assertEqual(user_info.call_count, 1)
192
+
169
193
 
170
194
  class RolesTest(TestCase):
171
195
  def setUp(self) -> None:
File without changes
File without changes
File without changes
File without changes