0001-general-remove-compatibility-with-django-1.11-38616.patch
debian/control | ||
---|---|---|
13 | 13 |
Architecture: all |
14 | 14 |
Depends: ${misc:Depends}, ${python:Depends}, |
15 | 15 |
python (>= 2.7), |
16 |
python-django (>= 1.5),
|
|
16 |
python-django (>= 1:1.11),
|
|
17 | 17 |
python-isodate, |
18 | 18 |
python-lasso, |
19 | 19 |
python-atomicwrites |
... | ... | |
23 | 23 |
Package: python3-django-mellon |
24 | 24 |
Architecture: all |
25 | 25 |
Depends: ${misc:Depends}, ${python:Depends}, |
26 |
python3-django (>= 1.5),
|
|
26 |
python3-django (>= 1:1.11),
|
|
27 | 27 |
python3-isodate, |
28 | 28 |
python3-lasso, |
29 | 29 |
python3-atomicwrites |
mellon/compat.py | ||
---|---|---|
1 |
# django-mellon - SAML2 authentication for Django |
|
2 |
# Copyright (C) 2014-2019 Entr'ouvert |
|
3 |
# This program is free software: you can redistribute it and/or modify |
|
4 |
# it under the terms of the GNU Affero General Public License as |
|
5 |
# published by the Free Software Foundation, either version 3 of the |
|
6 |
# License, or (at your option) any later version. |
|
7 | ||
8 |
# This program is distributed in the hope that it will be useful, |
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
# GNU Affero General Public License for more details. |
|
12 | ||
13 |
# You should have received a copy of the GNU Affero General Public License |
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | ||
16 |
import django |
|
17 |
if django.VERSION < (1, 11, 0): |
|
18 |
from django.core.urlresolvers import reverse |
|
19 |
MiddlewareClass = object |
|
20 | ||
21 |
is_authenticated = lambda user: user.is_authenticated() |
|
22 |
else: |
|
23 |
from django.urls import reverse |
|
24 |
from django.utils.deprecation import MiddlewareMixin |
|
25 |
MiddlewareClass = MiddlewareMixin |
|
26 | ||
27 |
is_authenticated = lambda user: user.is_authenticated |
mellon/middleware.py | ||
---|---|---|
17 | 17 | |
18 | 18 |
from django.utils.http import urlencode |
19 | 19 |
from django.http import HttpResponseRedirect |
20 |
from django.utils.deprecation import MiddlewareMixin |
|
21 |
from django.urls import reverse |
|
20 | 22 | |
21 | 23 |
from . import app_settings, utils |
22 |
from .compat import reverse, MiddlewareClass, is_authenticated |
|
23 | 24 | |
24 | 25 |
PASSIVE_TRIED_COOKIE = 'MELLON_PASSIVE_TRIED' |
25 | 26 | |
26 | 27 | |
27 |
class PassiveAuthenticationMiddleware(MiddlewareClass):
|
|
28 |
class PassiveAuthenticationMiddleware(MiddlewareMixin):
|
|
28 | 29 |
def process_response(self, request, response): |
29 | 30 |
# When unlogged remove the PASSIVE_TRIED cookie |
30 | 31 |
if app_settings.OPENED_SESSION_COOKIE_NAME \ |
... | ... | |
50 | 51 |
return |
51 | 52 |
if not app_settings.OPENED_SESSION_COOKIE_NAME: |
52 | 53 |
return |
53 |
if hasattr(request, 'user') and is_authenticated(request.user):
|
|
54 |
if hasattr(request, 'user') and request.user.is_authenticated:
|
|
54 | 55 |
return |
55 | 56 |
if PASSIVE_TRIED_COOKIE in request.COOKIES: |
56 | 57 |
return |
mellon/urls.py | ||
---|---|---|
14 | 14 |
url('metadata/$', views.metadata, |
15 | 15 |
name='mellon_metadata') |
16 | 16 |
] |
17 |
if django.VERSION < (1, 8): |
|
18 |
from django.conf.urls import patterns |
|
19 |
urlpatterns = patterns('', *urlpatterns) |
mellon/utils.py | ||
---|---|---|
25 | 25 |
import django |
26 | 26 |
from django.contrib import auth |
27 | 27 |
from django.template.loader import render_to_string |
28 |
from django.urls import reverse |
|
28 | 29 |
from django.utils.timezone import make_aware, now, make_naive, is_aware, get_default_timezone |
29 | 30 |
from django.conf import settings |
30 | 31 |
from django.utils.six.moves.urllib.parse import urlparse |
31 | 32 |
import lasso |
32 | 33 | |
33 | 34 |
from . import app_settings |
34 |
from .compat import reverse |
|
35 | 35 | |
36 | 36 | |
37 | 37 |
def create_metadata(request): |
mellon/views.py | ||
---|---|---|
30 | 30 |
from django.conf import settings |
31 | 31 |
from django.views.decorators.csrf import csrf_exempt |
32 | 32 |
from django.shortcuts import render, resolve_url |
33 |
from django.urls import reverse |
|
33 | 34 |
from django.utils.http import urlencode |
34 | 35 |
from django.utils import six |
35 | 36 |
from django.utils.encoding import force_text |
... | ... | |
38 | 39 |
from django.utils.translation import ugettext as _ |
39 | 40 | |
40 | 41 |
from . import app_settings, utils |
41 |
from .compat import reverse, is_authenticated |
|
42 | 42 | |
43 | 43 |
RETRY_LOGIN_COOKIE = 'MELLON_RETRY_LOGIN' |
44 | 44 | |
... | ... | |
529 | 529 |
next_url = request.GET.get(REDIRECT_FIELD_NAME) |
530 | 530 |
referer = request.META.get('HTTP_REFERER') |
531 | 531 |
if not referer or utils.same_origin(referer, request.build_absolute_uri()): |
532 |
if hasattr(request, 'user') and is_authenticated(request.user):
|
|
532 |
if hasattr(request, 'user') and request.user.is_authenticated:
|
|
533 | 533 |
logout = None |
534 | 534 |
try: |
535 | 535 |
issuer = request.session.get('mellon_session', {}).get('issuer') |
setup.py | ||
---|---|---|
91 | 91 |
include_package_data=True, |
92 | 92 |
packages=find_packages(), |
93 | 93 |
install_requires=[ |
94 |
'django>=1.7,<2.3',
|
|
94 |
'django>=1.11,<2.3',
|
|
95 | 95 |
'requests', |
96 | 96 |
'isodate', |
97 | 97 |
'atomicwrites', |
98 | 98 |
], |
99 | 99 |
setup_requires=[ |
100 |
'django>=1.7,<2',
|
|
100 |
'django>=1.10,<2.3',
|
|
101 | 101 |
], |
102 | 102 |
tests_require=[ |
103 | 103 |
'nose>=0.11.4', |
tests/test_sso_slo.py | ||
---|---|---|
26 | 26 |
import pytest |
27 | 27 |
from pytest import fixture |
28 | 28 | |
29 |
from django.urls import reverse |
|
29 | 30 |
from django.utils import six |
30 | 31 |
from django.utils.six.moves.urllib import parse as urlparse |
31 | 32 |
from django.utils.encoding import force_str |
... | ... | |
34 | 35 | |
35 | 36 |
from httmock import all_requests, HTTMock, response as mock_response |
36 | 37 | |
37 |
from mellon.compat import reverse |
|
38 | ||
39 | 38 |
from utils import reset_caplog |
40 | 39 | |
41 | 40 |
tests/test_views.py | ||
---|---|---|
25 | 25 |
from httmock import HTTMock |
26 | 26 | |
27 | 27 |
import django |
28 |
from django.urls import reverse |
|
28 | 29 |
from django.utils.encoding import force_text |
29 | 30 |
from django.utils.http import urlencode |
30 | 31 | |
31 | 32 |
from xml_utils import assert_xml_constraints |
32 | 33 | |
33 |
from mellon.compat import reverse |
|
34 | ||
35 | 34 |
from utils import error_500, html_response |
36 | 35 | |
37 | 36 |
pytestmark = pytest.mark.django_db |
testsettings.py | ||
---|---|---|
38 | 38 |
TEMPLATE_DIRS = [ |
39 | 39 |
'tests/templates/', |
40 | 40 |
] |
41 |
if django.VERSION >= (1, 8): |
|
42 |
TEMPLATES = [ |
|
43 |
{ |
|
44 |
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
45 |
'APP_DIRS': True, |
|
46 |
'DIRS': TEMPLATE_DIRS, |
|
47 |
}, |
|
48 |
] |
|
41 |
TEMPLATES = [ |
|
42 |
{ |
|
43 |
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
44 |
'APP_DIRS': True, |
|
45 |
'DIRS': TEMPLATE_DIRS, |
|
46 |
}, |
|
47 |
] |
tox.ini | ||
---|---|---|
1 | 1 |
[tox] |
2 |
envlist = coverage-py2-{dj18,dj111}-{pg,sqlite},coverage-py3-dj{111,22}-{pg,sqlite}
|
|
2 |
envlist = coverage-py2-dj111-{pg,sqlite},coverage-py3-dj{111,22}-{pg,sqlite}
|
|
3 | 3 |
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/django-mellon/ |
4 | 4 | |
5 | 5 |
[testenv] |
... | ... | |
14 | 14 |
usedevelop = |
15 | 15 |
coverage: true |
16 | 16 |
deps = |
17 |
dj18: django>=1.8,<1.9 |
|
18 | 17 |
dj111: django>=1.11,<1.12 |
19 | 18 |
dj22: django>=2.2,<2.3 |
20 | 19 |
pg: psycopg2 |
... | ... | |
30 | 29 |
pytz |
31 | 30 |
lxml |
32 | 31 |
cssselect |
33 |
dj18: django-webtest<1.9.3 |
|
34 | 32 |
dj111: django-webtest<1.9.3 |
35 | 33 |
dj22: django-webtest>1.9.3 |
36 | 34 |
WebTest |
37 |
- |