Skip to content

Commit a2e9b37

Browse files
authored
Merge pull request #210 from mcrowepfx/django_4_compatibility
Import changes for Django 4.0 compatibility
2 parents 399b90d + 7570d1e commit a2e9b37

File tree

7 files changed

+21
-10
lines changed

7 files changed

+21
-10
lines changed

.github/workflows/testing.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ jobs:
3939
python-version: 3.7
4040
- django-version: 4.0
4141
python-version: 3.6
42+
# DRF 3.10 is incompatible with Django v4
43+
- django-version: 4.0
44+
drf-version: 3.10
45+
- django-version: 4.0
46+
drf-version: 3.10
4247
steps:
4348
- uses: actions/checkout@v2
4449
- uses: actions/setup-python@v2

django_auth_adfs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
Adding imports here will break setup.py
55
"""
66

7-
__version__ = '1.9.3'
7+
__version__ = '1.9.4'

django_auth_adfs/drf_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
44
It's a bit of a hack, but DRF doesn't support overriding the login URL.
55
"""
6-
from django.conf.urls import url
6+
from django.urls import re_path
77

88
from django_auth_adfs import views
99

1010
app_name = "rest_framework"
1111

1212
urlpatterns = [
13-
url(r'^login$', views.OAuth2LoginView.as_view(), name='login'),
13+
re_path(r'^login$', views.OAuth2LoginView.as_view(), name='login'),
1414
]

django_auth_adfs/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.conf.urls import re_path
1+
from django.urls import re_path
22

33
from django_auth_adfs import views
44

django_auth_adfs/views.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from django.conf import settings as django_settings
55
from django.contrib.auth import authenticate, login, logout
66
from django.shortcuts import redirect
7-
from django.utils.http import is_safe_url
7+
try:
8+
from django.utils.http import url_has_allowed_host_and_scheme
9+
except ImportError:
10+
# Django <3.0
11+
from django.utils.http import is_safe_url as url_has_allowed_host_and_scheme
812
from django.views.generic import View
913

1014
from django_auth_adfs.config import provider_config, settings
@@ -47,7 +51,7 @@ def get(self, request):
4751
redirect_to = base64.urlsafe_b64decode(redirect_to.encode()).decode()
4852
else:
4953
redirect_to = django_settings.LOGIN_REDIRECT_URL
50-
url_is_safe = is_safe_url(
54+
url_is_safe = url_has_allowed_host_and_scheme(
5155
url=redirect_to,
5256
allowed_hosts=[request.get_host()],
5357
require_https=request.is_secure(),

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = 'django-auth-adfs'
3-
version = "1.9.3" # Remember to also change __init__.py version
3+
version = "1.9.4" # Remember to also change __init__.py version
44
description = 'A Django authentication backend for Microsoft ADFS and AzureAD'
55
authors = ['Joris Beckers <[email protected]>']
66
maintainers = ['Jonas Krüger Svensson <[email protected]>', 'Sondre Lillebø Gundersen <[email protected]>']
@@ -15,6 +15,8 @@ classifiers = [
1515
'Framework :: Django :: 2.2',
1616
'Framework :: Django :: 3.0',
1717
'Framework :: Django :: 3.1',
18+
'Framework :: Django :: 3.2',
19+
'Framework :: Django :: 4.0',
1820
'Intended Audience :: Developers',
1921
'Intended Audience :: End Users/Desktop',
2022
'Operating System :: OS Independent',

tests/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from django.conf.urls import url, include
1+
from django.urls import include, re_path
22

33
urlpatterns = [
4-
url(r'^oauth2/', include('django_auth_adfs.urls')),
5-
url(r'^oauth2/', include('django_auth_adfs.drf_urls')),
4+
re_path(r'^oauth2/', include('django_auth_adfs.urls')),
5+
re_path(r'^oauth2/', include('django_auth_adfs.drf_urls')),
66
]

0 commit comments

Comments
 (0)