Skip to content

Commit

Permalink
remove django 3.2 support (which has reached end of life, and is no l…
Browse files Browse the repository at this point in the history
…onger supported by django or django-allauth) and some minor additional fixes to use of datetime module
  • Loading branch information
dpgraham4401 committed Dec 1, 2024
1 parent 65f7d1a commit 41a21e2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
10 changes: 5 additions & 5 deletions dj_rest_auth/jwt_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import timezone
from datetime import datetime
from django.utils.translation import gettext_lazy as _
from rest_framework import status
from rest_framework import exceptions, serializers
Expand All @@ -12,7 +12,7 @@
def set_jwt_access_cookie(response, access_token):
from rest_framework_simplejwt.settings import api_settings as jwt_settings
cookie_name = api_settings.JWT_AUTH_COOKIE
access_token_expiration = (timezone.now() + jwt_settings.ACCESS_TOKEN_LIFETIME)
access_token_expiration = (datetime.utcnow() + jwt_settings.ACCESS_TOKEN_LIFETIME)
cookie_secure = api_settings.JWT_AUTH_SECURE
cookie_httponly = api_settings.JWT_AUTH_HTTPONLY
cookie_samesite = api_settings.JWT_AUTH_SAMESITE
Expand All @@ -32,7 +32,7 @@ def set_jwt_access_cookie(response, access_token):

def set_jwt_refresh_cookie(response, refresh_token):
from rest_framework_simplejwt.settings import api_settings as jwt_settings
refresh_token_expiration = (timezone.now() + jwt_settings.REFRESH_TOKEN_LIFETIME)
refresh_token_expiration = (datetime.utcnow() + jwt_settings.REFRESH_TOKEN_LIFETIME)
refresh_cookie_name = api_settings.JWT_AUTH_REFRESH_COOKIE
refresh_cookie_path = api_settings.JWT_AUTH_REFRESH_COOKIE_PATH
cookie_secure = api_settings.JWT_AUTH_SECURE
Expand Down Expand Up @@ -101,13 +101,13 @@ class RefreshViewWithCookieSupport(TokenRefreshView):
def finalize_response(self, request, response, *args, **kwargs):
if response.status_code == status.HTTP_200_OK and 'access' in response.data:
set_jwt_access_cookie(response, response.data['access'])
response.data['access_expiration'] = (timezone.now() + jwt_settings.ACCESS_TOKEN_LIFETIME)
response.data['access_expiration'] = (datetime.utcnow() + jwt_settings.ACCESS_TOKEN_LIFETIME)
if response.status_code == status.HTTP_200_OK and 'refresh' in response.data:
set_jwt_refresh_cookie(response, response.data['refresh'])
if api_settings.JWT_AUTH_HTTPONLY:
del response.data['refresh']
else:
response.data['refresh_expiration'] = (timezone.now() + jwt_settings.REFRESH_TOKEN_LIFETIME)
response.data['refresh_expiration'] = (datetime.utcnow() + jwt_settings.REFRESH_TOKEN_LIFETIME)
return super().finalize_response(request, response, *args, **kwargs)
return RefreshViewWithCookieSupport

Expand Down
6 changes: 0 additions & 6 deletions dj_rest_auth/tests/requirements.pip
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
coveralls==1.11.1
django-allauth==64.0.0
djangorestframework-simplejwt>=5.3.1
flake8==3.8.4
responses==0.12.1
unittest-xml-reporting==3.2.0
1 change: 1 addition & 0 deletions dj_rest_auth/tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ djangorestframework-simplejwt>=5.3.1
flake8==3.8.4
responses==0.12.1
unittest-xml-reporting==3.0.4
requests-oauthlib==2.0.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
keywords='django rest auth registration rest-framework django-registration api',
zip_safe=False,
install_requires=[
'Django>=3.2,<6.0',
'Django>=4.2,<6.0',
'djangorestframework>=3.13.0',
],
extras_require={
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ commands =
python ./runtests.py
deps =
-r dj_rest_auth/tests/requirements.txt
django3: Django>=3.2,<4.0
django4: Django>=4.0,<5.0
django4: Django>=4.2,<5.0
django5: Django>=5.0,<6.0

# Configuration for coverage and flake8 is being set in `./setup.cfg`
Expand Down

0 comments on commit 41a21e2

Please sign in to comment.