Skip to content

Commit 821de3d

Browse files
authored
Merge pull request #403 from akatsoulas/drop-unmaintained-versions
Drop unmaintained Python and Django versions
2 parents 7c4c58c + b411294 commit 821de3d

File tree

11 files changed

+106
-174
lines changed

11 files changed

+106
-174
lines changed

.circleci/config.yml

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -51,119 +51,75 @@ jobs:
5151
root: workspace
5252
paths:
5353
- mozilla-django-oidc-dev.tar.gz
54-
e2e_test_py2_rs_django111:
55-
docker:
56-
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py2-latest
57-
name: testoidcsetup
58-
environment:
59-
- TEST_OIDC_ALGO=rs
60-
- DJANGO_VERSION=Django>=1.11,<2.0.0
61-
<<: *common_steps
62-
e2e_test_py3_rs_django111:
63-
docker:
64-
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
65-
name: testoidcsetup
66-
environment:
67-
- TEST_OIDC_ALGO=rs
68-
- DJANGO_VERSION=Django>=1.11,<2.0.0
69-
<<: *common_steps
70-
e2e_test_py3_rs_django200:
71-
docker:
72-
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
73-
name: testoidcsetup
74-
environment:
75-
- TEST_OIDC_ALGO=rs
76-
- DJANGO_VERSION=Django>=2.0.0,<2.1
77-
<<: *common_steps
78-
e2e_test_py3_rs_django210:
54+
e2e_test_py3_rs_django220:
7955
docker:
8056
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
8157
name: testoidcsetup
8258
environment:
8359
- TEST_OIDC_ALGO=rs
84-
- DJANGO_VERSION=Django>=2.1.0,<2.2
85-
<<: *common_steps
86-
e2e_test_py2_hs_django111:
87-
docker:
88-
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py2-latest
89-
name: testoidcsetup
90-
environment:
91-
- TEST_OIDC_ALGO=hs
92-
- DJANGO_VERSION=Django>=1.11,<2.0.0
60+
- DJANGO_VERSION=Django>=2.2.0,<3.0
9361
<<: *common_steps
94-
e2e_test_py3_hs_django111:
62+
e2e_test_py3_hs_django220:
9563
docker:
9664
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
9765
name: testoidcsetup
9866
environment:
9967
- TEST_OIDC_ALGO=hs
100-
- DJANGO_VERSION=Django>=1.11,<2.0.0
68+
- DJANGO_VERSION=Django>=2.2.0,<3.0
10169
<<: *common_steps
102-
e2e_test_py3_hs_django200:
70+
e2e_test_py3_rs_django300:
10371
docker:
10472
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
10573
name: testoidcsetup
10674
environment:
107-
- TEST_OIDC_ALGO=hs
108-
- DJANGO_VERSION=Django>=2.0.0,<2.1
75+
- TEST_OIDC_ALGO=rs
76+
- DJANGO_VERSION=Django>=3.0.0,<3.1
10977
<<: *common_steps
110-
e2e_test_py3_hs_django210:
78+
e2e_test_py3_hs_django300:
11179
docker:
11280
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
11381
name: testoidcsetup
11482
environment:
11583
- TEST_OIDC_ALGO=hs
116-
- DJANGO_VERSION=Django>=2.1.0,<2.2
84+
- DJANGO_VERSION=Django>=3.0.0,<3.1
11785
<<: *common_steps
118-
e2e_test_py3_hs_django220:
86+
e2e_test_py3_rs_django310:
11987
docker:
12088
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
12189
name: testoidcsetup
12290
environment:
123-
- TEST_OIDC_ALGO=hs
124-
- DJANGO_VERSION=Django>=2.2.0,<3.0
91+
- TEST_OIDC_ALGO=rs
92+
- DJANGO_VERSION=Django>=3.1.0,<3.2
12593
<<: *common_steps
126-
e2e_test_py3_hs_django300:
94+
e2e_test_py3_hs_django310:
12795
docker:
12896
- image: mozilla/oidc-testprovider:oidc_e2e_setup_py3-latest
12997
name: testoidcsetup
13098
environment:
13199
- TEST_OIDC_ALGO=hs
132-
- DJANGO_VERSION=Django>=3.0.0,<3.1
100+
- DJANGO_VERSION=Django>=3.1.0,<3.2
133101
<<: *common_steps
134102

135103
workflows:
136104
version: 2
137105
build_and_test:
138106
jobs:
139107
- build_lib
140-
- e2e_test_py2_rs_django111:
108+
- e2e_test_py3_rs_django220:
141109
requires:
142110
- build_lib
143-
- e2e_test_py2_hs_django111:
144-
requires:
145-
- build_lib
146-
- e2e_test_py3_rs_django111:
147-
requires:
148-
- build_lib
149-
- e2e_test_py3_hs_django111:
150-
requires:
151-
- build_lib
152-
- e2e_test_py3_rs_django200:
153-
requires:
154-
- build_lib
155-
- e2e_test_py3_hs_django200:
111+
- e2e_test_py3_hs_django220:
156112
requires:
157113
- build_lib
158-
- e2e_test_py3_rs_django210:
114+
- e2e_test_py3_rs_django300:
159115
requires:
160116
- build_lib
161-
- e2e_test_py3_hs_django210:
117+
- e2e_test_py3_hs_django300:
162118
requires:
163119
- build_lib
164-
- e2e_test_py3_hs_django220:
120+
- e2e_test_py3_rs_django310:
165121
requires:
166122
- build_lib
167-
- e2e_test_py3_hs_django300:
123+
- e2e_test_py3_hs_django310:
168124
requires:
169125
- build_lib

mozilla_django_oidc/auth.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.contrib.auth.backends import ModelBackend
1111
from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
1212
from django.urls import reverse
13-
from django.utils.encoding import force_bytes, smart_text, smart_bytes
13+
from django.utils.encoding import force_bytes, smart_str, smart_bytes
1414
from django.utils.module_loading import import_string
1515

1616
from josepy.b64 import b64decode
@@ -38,7 +38,7 @@ def default_username_algo(email):
3838
hashlib.sha1(force_bytes(email)).digest()
3939
).rstrip(b'=')
4040

41-
return smart_text(username)
41+
return smart_str(username)
4242

4343

4444
class OIDCAuthenticationBackend(ModelBackend):
@@ -159,9 +159,9 @@ def retrieve_matching_jwk(self, token):
159159
key = None
160160
for jwk in jwks['keys']:
161161
if (import_from_settings("OIDC_VERIFY_KID", True)
162-
and jwk['kid'] != smart_text(header.kid)):
162+
and jwk['kid'] != smart_str(header.kid)):
163163
continue
164-
if 'alg' in jwk and jwk['alg'] != smart_text(header.alg):
164+
if 'alg' in jwk and jwk['alg'] != smart_str(header.alg):
165165
continue
166166
key = jwk
167167
if key is None:
@@ -172,7 +172,7 @@ def get_payload_data(self, token, key):
172172
"""Helper method to get the payload of the JWT token."""
173173
if self.get_settings('OIDC_ALLOW_UNSECURED_JWT', False):
174174
header, payload_data, signature = token.split(b'.')
175-
header = json.loads(smart_text(b64decode(header)))
175+
header = json.loads(smart_str(b64decode(header)))
176176

177177
# If config allows unsecured JWTs check the header and return the decoded payload
178178
if 'alg' in header and header['alg'] == 'none':

mozilla_django_oidc/middleware.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
add_state_and_nonce_to_session,
1515
import_from_settings)
1616

17-
try:
18-
from urllib.parse import urlencode
19-
except ImportError:
20-
# Python < 3
21-
from urllib import urlencode
17+
from urllib.parse import urlencode
2218

2319
try:
2420
# Python 3.7 or later
@@ -166,7 +162,7 @@ def process_request(self, request):
166162

167163
query = urlencode(params)
168164
redirect_url = '{url}?{query}'.format(url=auth_url, query=query)
169-
if request.is_ajax():
165+
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
170166
# Almost all XHR request handling in client-side code struggles
171167
# with redirects since redirecting to a page where the user
172168
# is supposed to do something is extremely unlikely to work

mozilla_django_oidc/urls.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.conf.urls import url
1+
from django.urls import path
22
from django.utils.module_loading import import_string
33

44
from mozilla_django_oidc import views
@@ -18,9 +18,7 @@
1818
OIDCAuthenticateClass = import_string(AUTHENTICATE_CLASS_PATH)
1919

2020
urlpatterns = [
21-
url(r'^callback/$', OIDCCallbackClass.as_view(),
22-
name='oidc_authentication_callback'),
23-
url(r'^authenticate/$', OIDCAuthenticateClass.as_view(),
24-
name='oidc_authentication_init'),
25-
url(r'^logout/$', views.OIDCLogoutView.as_view(), name='oidc_logout'),
21+
path('callback/', OIDCCallbackClass.as_view(), name='oidc_authentication_callback'),
22+
path('authenticate/', OIDCAuthenticateClass.as_view(), name='oidc_authentication_init'),
23+
path('logout/', views.OIDCLogoutView.as_view(), name='oidc_logout'),
2624
]

mozilla_django_oidc/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
from django.conf import settings
66
from django.core.exceptions import ImproperlyConfigured
77

8-
try:
9-
from urllib.request import parse_http_list, parse_keqv_list
10-
except ImportError:
11-
# python < 3
12-
from urllib2 import parse_http_list, parse_keqv_list
8+
from urllib.request import parse_http_list, parse_keqv_list
139

1410

1511
LOGGER = logging.getLogger(__name__)

mozilla_django_oidc/views.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
from django.http import HttpResponseRedirect
66
from django.urls import reverse
77
from django.utils.crypto import get_random_string
8-
from django.utils.http import is_safe_url
8+
9+
try:
10+
from django.utils.http import url_has_allowed_host_and_scheme
11+
except ImportError:
12+
# Django <= 2.2
13+
from django.utils.http import is_safe_url as url_has_allowed_host_and_scheme
14+
915
from django.utils.module_loading import import_string
1016
from django.views.generic import View
1117

1218
from mozilla_django_oidc.utils import (absolutify,
1319
add_state_and_nonce_to_session,
1420
import_from_settings)
1521

16-
try:
17-
from urllib.parse import urlencode
18-
except ImportError:
19-
# Python < 3
20-
from urllib import urlencode
22+
from urllib.parse import urlencode
2123

2224

2325
class OIDCAuthenticationCallbackView(View):
@@ -127,7 +129,7 @@ def get_next_url(request, redirect_field_name):
127129
hosts.append(request.get_host())
128130
kwargs['allowed_hosts'] = hosts
129131

130-
is_safe = is_safe_url(**kwargs)
132+
is_safe = url_has_allowed_host_and_scheme(**kwargs)
131133
if is_safe:
132134
return next_url
133135
return None

tests/namespaced_urls.py

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

3-
urlpatterns = [url(r'^namespace/', include(('mozilla_django_oidc.urls', 'namespace')))]
3+
urlpatterns = [path('namespace/', include(('mozilla_django_oidc.urls', 'namespace')))]

0 commit comments

Comments
 (0)