From 802fef95fa1c59a1b5e1715910426268c97f3b6f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:07:32 +0100 Subject: [PATCH 1/6] Add Django 3.1 and Python 3.9 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO Signed-off-by: Yohann D'ANELLO --- .travis.yml | 6 +++ README.rst | 4 +- setup.py | 4 +- tox.ini | 112 +++++++++++++++++++++------------------------------- 4 files changed, 55 insertions(+), 71 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f0543b..cf7fa85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,12 @@ matrix: - python: "3.8" env: TOX_ENV=py38-django30 - python: "3.8" + env: TOX_ENV=py38-django31 + - python: "3.9" + env: TOX_ENV=py39-django30 + - python: "3.9" + env: TOX_ENV=py39-django31 + - python: "3.9" env: TOX_ENV=coverage cache: directories: diff --git a/README.rst b/README.rst index 87b663f..afd3fba 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ Features * Possibility to rename/rewrite attributes per service * Possibility to require some attribute values per service * Federated mode between multiple CAS -* Supports Django 1.11, 2.2 and 3.0 +* Supports Django 1.11, 2.2 and 3.1 * Supports Python 2.7, 3.5+ Dependencies @@ -29,7 +29,7 @@ Dependencies ``django-cas-server`` depends on the following python packages: -* Django >= 1.11 < 3.1 +* Django >= 1.11 < 3.2 * requests >= 2.4 * requests_futures >= 0.9.5 * lxml >= 3.4 diff --git a/setup.py b/setup.py index 38cfb70..417892e 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ if __name__ == '__main__': 'Framework :: Django :: 2.1', 'Framework :: Django :: 2.2', 'Framework :: Django :: 3.0', + 'Framework :: Django :: 3.1', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', @@ -48,6 +49,7 @@ if __name__ == '__main__': 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', @@ -62,7 +64,7 @@ if __name__ == '__main__': }, keywords=['django', 'cas', 'cas3', 'server', 'sso', 'single sign-on', 'authentication', 'auth'], install_requires=[ - 'Django >= 1.11,<3.1', 'requests >= 2.4', 'requests_futures >= 0.9.5', + 'Django >= 1.11,<3.2', 'requests >= 2.4', 'requests_futures >= 0.9.5', 'lxml >= 3.4', 'six >= 1' ], url="https://github.com/nitmir/django-cas-server", diff --git a/tox.ini b/tox.ini index c398c06..a8a45d5 100644 --- a/tox.ini +++ b/tox.ini @@ -9,9 +9,15 @@ envlist= py36-django22, py37-django22, py38-django22, + py39-django22, py36-django30, py37-django30, py38-django30, + py39-django30, + py36-django31, + py37-django31, + py38-django31, + py39-django31, [flake8] max-line-length=100 @@ -37,54 +43,12 @@ commands= {[post_cmd]commands} whitelist_externals={[post_cmd]whitelist_externals} -[testenv:py27-django17] -basepython=python2.7 -deps = - Django>=1.7,<1.8 - {[base]deps} - -[testenv:py27-django18] -basepython=python2.7 -deps = - Django>=1.8,<1.9 - {[base]deps} - -[testenv:py27-django19] -basepython=python2.7 -deps = - Django>=1.9,<1.10 - {[base]deps} - -[testenv:py27-django110] -basepython=python2.7 -deps = - Django>=1.10,<1.11 - {[base]deps} - [testenv:py27-django111] basepython=python2.7 deps = Django>=1.11,<1.12 {[base]deps} -[testenv:py34-django17] -basepython=python3.4 -deps = - Django>=1.7,<1.8 - {[base]deps} - -[testenv:py34-django18] -basepython=python3.4 -deps = - Django>=1.8,<1.9 - {[base]deps} - -[testenv:py35-django110] -basepython=python3.5 -deps = - Django>=1.10,<1.11 - {[base]deps} - [testenv:py35-django111] basepython=python3.5 deps = @@ -97,34 +61,10 @@ deps = Django>=1.11,<1.12 {[base]deps} -[testenv:py35-django20] -basepython=python3.5 -deps = - Django>=2.0,<2.1 - {[base]deps} - -[testenv:py36-django20] -basepython=python3.6 -deps = - Django>=2.0,<2.1 - {[base]deps} - -[testenv:py35-django21] -basepython=python3.5 -deps = - Django>=2.1,<2.2 - {[base]deps} - -[testenv:py36-django21] -basepython=python3.6 -deps = - Django>=2.1,<2.2 - {[base]deps} - -[testenv:py37-django21] +[testenv:py37-django111] basepython=python3.7 deps = - Django>=2.1,<2.2 + Django>=1.11,<1.12 {[base]deps} [testenv:py36-django22] @@ -145,6 +85,12 @@ deps = Django>=2.2,<3.0 {[base]deps} +[testenv:py39-django22] +basepython=python3.9 +deps = + Django>=2.2,<3.0 + {[base]deps} + [testenv:py36-django30] basepython=python3.6 deps = @@ -163,6 +109,36 @@ deps = Django>=3.0,<3.1 {[base]deps} +[testenv:py39-django30] +basepython=python3.9 +deps = + Django>=3.0,<3.1 + {[base]deps} + +[testenv:py36-django31] +basepython=python3.6 +deps = + Django>=3.1,<3.2 + {[base]deps} + +[testenv:py37-django31] +basepython=python3.7 +deps = + Django>=3.1,<3.2 + {[base]deps} + +[testenv:py38-django31] +basepython=python3.8 +deps = + Django>=3.1,<3.2 + {[base]deps} + +[testenv:py39-django31] +basepython=python3.9 +deps = + Django>=3.1,<3.2 + {[base]deps} + [testenv:flake8] basepython=python3 From 10b389e7bebf5770c9ff7840acc9943eb2474b52 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:07:33 +0100 Subject: [PATCH 2/6] With Python 3.9, the crypt function raises an OSError See https://bugs.python.org/issue39289 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO Signed-off-by: Yohann D'ANELLO --- cas_server/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cas_server/utils.py b/cas_server/utils.py index f2bb4db..4ec2333 100644 --- a/cas_server/utils.py +++ b/cas_server/utils.py @@ -409,7 +409,10 @@ def crypt_salt_is_valid(salt): if '$' not in salt[1:]: return False else: - hashed = crypt.crypt("", salt) + try: + hashed = crypt.crypt("", salt) + except OSError: + return False if not hashed or '$' not in hashed[1:]: return False else: From d62def6d6b1b7d94e520567f7b58f2a65e181f71 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:07:33 +0100 Subject: [PATCH 3/6] django.conf.urls is deprecated and will be removed in Django 4.0, use django.urls.re_path instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO Signed-off-by: Yohann D'ANELLO --- cas_server/tests/urls.py | 14 ++++++++++++-- cas_server/urls.py | 35 +++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/cas_server/tests/urls.py b/cas_server/tests/urls.py index a9ed25c..b95c228 100644 --- a/cas_server/tests/urls.py +++ b/cas_server/tests/urls.py @@ -13,10 +13,20 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ + +import django + +if django.VERSION < (2,): + from django.conf.urls import url + re_path = url +else: + from django.urls import re_path + + from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^', include('cas_server.urls', namespace='cas_server')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^', include('cas_server.urls', namespace='cas_server')), ] diff --git a/cas_server/urls.py b/cas_server/urls.py index 1e874c0..680c61e 100644 --- a/cas_server/urls.py +++ b/cas_server/urls.py @@ -10,6 +10,16 @@ # # (c) 2015-2016 Valentin Samir """urls for the app""" + +import django + +if django.VERSION < (2,): + from django.conf.urls import url + re_path = url +else: + from django.urls import re_path + + from django.conf.urls import url from django.views.generic import RedirectView from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables @@ -19,42 +29,42 @@ from cas_server import views app_name = "cas_server" urlpatterns = [ - url( + re_path( r'^$', RedirectView.as_view(pattern_name="cas_server:login", permanent=False, query_string=True) ), - url( + re_path( '^login$', sensitive_post_parameters('password')( views.LoginView.as_view() ), name='login' ), - url('^logout$', views.LogoutView.as_view(), name='logout'), - url('^validate$', views.Validate.as_view(), name='validate'), - url( + re_path('^logout$', views.LogoutView.as_view(), name='logout'), + re_path('^validate$', views.Validate.as_view(), name='validate'), + re_path( '^serviceValidate$', views.ValidateService.as_view(allow_proxy_ticket=False), name='serviceValidate' ), - url( + re_path( '^proxyValidate$', views.ValidateService.as_view(allow_proxy_ticket=True), name='proxyValidate' ), - url('^proxy$', views.Proxy.as_view(), name='proxy'), - url( + re_path('^proxy$', views.Proxy.as_view(), name='proxy'), + re_path( '^p3/serviceValidate$', views.ValidateService.as_view(allow_proxy_ticket=False), name='p3_serviceValidate' ), - url( + re_path( '^p3/proxyValidate$', views.ValidateService.as_view(allow_proxy_ticket=True), name='p3_proxyValidate' ), - url('^samlValidate$', views.SamlValidate.as_view(), name='samlValidate'), - url( + re_path('^samlValidate$', views.SamlValidate.as_view(), name='samlValidate'), + re_path( '^auth$', sensitive_variables('password', 'secret')( sensitive_post_parameters('password', 'secret')( @@ -63,5 +73,6 @@ urlpatterns = [ ), name='auth' ), - url("^federate(?:/(?P([^/]+)))?$", views.FederateAuth.as_view(), name='federateAuth'), + re_path("^federate(?:/(?P([^/]+)))?$", + views.FederateAuth.as_view(), name='federateAuth'), ] From 251cfb9b49c3fa2c57d4526399f07339f3324e63 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:07:33 +0100 Subject: [PATCH 4/6] Construct a middleware without a get_response function is deprecated and will not work in a future release. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO Signed-off-by: Yohann D'ANELLO --- cas_server/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cas_server/views.py b/cas_server/views.py index a1f2873..bbf5490 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -288,7 +288,8 @@ class FederateAuth(CsrfExemptView): # else, a User is trying to log in using an identity provider except FederatedIendityProvider.DoesNotExist: # Manually checking for csrf to protect the code below - reason = CsrfViewMiddleware().process_view(request, None, (), {}) + reason = CsrfViewMiddleware(lambda request: HttpResponse()) \ + .process_view(request, None, (), {}) if reason is not None: # pragma: no cover (csrf checks are disabled during tests) return reason # Failed the test, stop here. form = forms.FederateSelect(request.POST) From 2a07cca1f1080e9b45a8bd6f735568dc9e8ca1fc Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:42:58 +0100 Subject: [PATCH 5/6] Support for Django 2.0 and 2.1 was dropped Signed-off-by: Yohann D'ANELLO --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf7fa85..ca142f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,6 @@ matrix: env: TOX_ENV=py35-django111 - python: "3.6" env: TOX_ENV=py36-django111 - - python: "3.5" - env: TOX_ENV=py35-django20 - - python: "3.6" - env: TOX_ENV=py36-django20 - - python: "3.5" - env: TOX_ENV=py35-django21 - - python: "3.6" - env: TOX_ENV=py36-django21 - python: "3.7" env: TOX_ENV=py37-django22 - python: "3.8" From ba9cfaf1dc6d98c66d61869b6b035b413b92bde2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 26 Jan 2021 14:53:51 +0100 Subject: [PATCH 6/6] Update test environment, don't test anymore with Django 2.0 and Django 2.1 Signed-off-by: Yohann D'ANELLO --- .gitlab-ci.yml | 159 +++++++++++++++++++++++-------------------------- .travis.yml | 6 +- 2 files changed, 79 insertions(+), 86 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cffb395..0394afa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ before_script: - pip install tox setuptools flake8: - image: "python:2.7" + image: "python:3.9" cache: key: flake8 paths: @@ -11,7 +11,7 @@ flake8: - tox -e flake8 check_rst: - image: "python:2.7" + image: "python:3.9" cache: key: check_rst paths: @@ -19,107 +19,98 @@ check_rst: script: - tox -e check_rst -py27-django17: +py27-django111: image: "python:2.7" cache: - key: py27-django17 + key: py27-django111 paths: - - .tox/py27-django17 + - .tox/py27-django111 script: - - tox -e py27-django17 + - tox -e py27-django111 -py27-django18: - image: "python:2.7" - cache: - key: py27-django18 - paths: - - .tox/py27-django18 - script: - - tox -e py27-django18 - -py27-django19: - image: "python:2.7" - cache: - key: py27-django19 - paths: - - .tox/py27-django19 - script: - - tox -e py27-django19 - -py27-django110: - image: "python:2.7" - cache: - key: py27-django110 - paths: - - .tox/py27-django110 - script: - - tox -e py27-django110 - -py34-django17: - image: "python:3.4" - cache: - key: py34-django17 - paths: - - .tox/py34-django17 - script: - - tox -e py34-django17 - -py34-django18: - image: "python:3.4" - cache: - key: py34-django18 - paths: - - .tox/py34-django18 - script: - - tox -e py34-django18 - -py34-django19: - image: "python:3.4" - cache: - key: py34-django19 - paths: - - .tox/py34-django19 - script: - - tox -e py34-django19 - -py34-django110: - image: "python:3.4" - cache: - key: py34-django110 - paths: - - .tox/py34-django110 - script: - - tox -e py34-django110 - -py35-django18: +py35-django111: image: "python:3.5" cache: - key: py35-django18 + key: py35-django111 paths: - - .tox/py35-django18 + - .tox/py35-django111 script: - - tox -e py35-django18 + - tox -e py35-django111 -py35-django19: - image: "python:3.5" +py36-django111: + image: "python:3.6" cache: - key: py35-django19 + key: py36-django111 paths: - - .tox/py35-django19 + - .tox/py36-django111 script: - - tox -e py35-django19 + - tox -e py36-django111 -py35-django110: - image: "python:3.5" +py37-django22: + image: "python:3.7" cache: - key: py35-django110 + key: py37-django22 paths: - - .tox/py35-django110 + - .tox/py37-django22 script: - - tox -e py35-django110 + - tox -e py37-django22 + +py38-django22: + image: "python:3.8" + cache: + key: py38-django22 + paths: + - .tox/py38-django22 + script: + - tox -e py38-django22 + +py38-django30: + image: "python:3.8" + cache: + key: py38-django30 + paths: + - .tox/py38-django30 + script: + - tox -e py38-django30 + +py38-django31: + image: "python:3.8" + cache: + key: py38-django31 + paths: + - .tox/py38-django31 + script: + - tox -e py38-django31 + +py39-django22: + image: "python:3.9" + cache: + key: py39-django22 + paths: + - .tox/py39-django22 + script: + - tox -e py39-django22 + +py39-django30: + image: "python:3.9" + cache: + key: py39-django30 + paths: + - .tox/py39-django30 + script: + - tox -e py39-django30 + +py39-django31: + image: "python:3.9" + cache: + key: py39-django31 + paths: + - .tox/py39-django31 + script: + - tox -e py39-django31 coverage: - image: "python:2.7" + image: "python:3.9" cache: key: coverage paths: diff --git a/.travis.yml b/.travis.yml index ca142f3..cd7a9bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python matrix: include: - - python: "3.8" + - python: "3.9" env: TOX_ENV=flake8 - - python: "3.8" + - python: "3.9" env: TOX_ENV=check_rst - python: "2.7" env: TOX_ENV=py27-django111 @@ -19,6 +19,8 @@ matrix: env: TOX_ENV=py38-django30 - python: "3.8" env: TOX_ENV=py38-django31 + - python: "3.9" + env: TOX_ENV=py39-django22 - python: "3.9" env: TOX_ENV=py39-django30 - python: "3.9"