Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Support Django 1.10, drop support for Django < 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-moth committed Nov 21, 2016
1 parent 654f38d commit a785e3f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 58 deletions.
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,24 @@ cache: pip

matrix:
include:
- env: TOXENV=py27-dj15
python: 2.7
- env: TOXENV=py27-dj16
python: 2.7
- env: TOXENV=py27-dj17
python: 2.7
- env: TOXENV=py27-dj18
python: 2.7
- env: TOXENV=py27-dj19
python: 2.7
- env: TOXENV=py34-dj17
python: 3.4
- env: TOXENV=py27-dj110
python: 2.7
- env: TOXENV=py34-dj18
python: 3.4
- env: TOXENV=py34-dj19
python: 3.4
- env: TOXENV=py34-dj15
- env: TOXENV=py34-dj110
python: 3.4
- env: TOXENV=py35-dj18
python: 3.5
- env: TOXENV=py35-dj19
python: 3.5
- env: TOXENV=py35-dj110
python: 3.5

install:
- pip install tox
Expand Down
22 changes: 9 additions & 13 deletions idptest/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'q+0vb%)c7c%&kl&jcca^6n7$3q4ktle9i28t(fd&qh28%l-%58'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': [
'%s/templates' % PROJECT_ROOT,
],
}
]

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
Expand All @@ -85,13 +88,6 @@

ROOT_URLCONF = 'idptest.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'%s/templates' % PROJECT_ROOT,
)

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
Expand Down
14 changes: 7 additions & 7 deletions idptest/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from django.conf.urls import patterns, include

import django.contrib.auth.views
from django.conf.urls import include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
urlpatterns = [
# Example:
# (r'^idptest/', include('idptest.foo.urls')),

Expand All @@ -15,11 +15,11 @@
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include(admin.site.urls)),

# Required for login:
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url(r'^accounts/login/$', django.contrib.auth.views.login),

# URLs for the IDP:
(r'^idp/', include('saml2idp.urls')),
)
url(r'^idp/', include('saml2idp.urls')),
]
28 changes: 8 additions & 20 deletions saml2idp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.urlresolvers import reverse
from django.utils.datastructures import MultiValueDictKeyError
from django.shortcuts import render_to_response, redirect
from django.shortcuts import render, redirect
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt

from . import saml2idp_metadata
Expand All @@ -23,12 +22,7 @@

logger = get_saml_logger()

# The 'schemes' argument for the URLValidator was introduced in Django 1.6. This
# ensure that URL validation works in 1.5 as well.
try:
URL_VALIDATOR = URLValidator(schemes=('http', 'https'))
except TypeError:
URL_VALIDATOR = URLValidator()
URL_VALIDATOR = URLValidator(schemes=('http', 'https'))

BASE_TEMPLATE_DIR = 'saml2idp'

Expand All @@ -55,17 +49,14 @@ def _generate_response(request, processor):
tv = processor.generate_response()
except exceptions.UserNotAuthorized:
template_names = _get_template_names('invalid_user.html', processor)
return render_to_response(template_names,
context_instance=RequestContext(request))
return render(request, template_names)

template_names = _get_template_names('login.html', processor)
return render_to_response(template_names,
tv,
context_instance=RequestContext(request))
return render(request, template_names, tv)


def xml_response(request, template, tv):
return render_to_response(template, tv, content_type="application/xml")
return render(request, template, tv, content_type="application/xml")


@csrf_exempt
Expand Down Expand Up @@ -141,9 +132,7 @@ def logout(request):
else:
return HttpResponseRedirect(redirect_url)

return render_to_response(_get_template_names('logged_out.html'),
{},
context_instance=RequestContext(request))
return render(request, _get_template_names('logged_out.html'), {})


@login_required
Expand All @@ -162,9 +151,8 @@ def slo_logout(request):
#XXX: For now, simply log out without validating the request.
auth.logout(request)
tv = {}
return render_to_response(_get_template_names('logged_out.html'),
tv,
context_instance=RequestContext(request))
return render(request, _get_template_names('logged_out.html'),
tv)


def descriptor(request):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description='SAML 2.0 IdP for Django',
long_description='\n\n'.join([description, changelog]),
install_requires=[
'Django>=1.4',
'Django>=1.8',
'pyopenssl>=0.16',
'BeautifulSoup4>=4.4.0',
'lxml',
Expand Down
14 changes: 6 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ skipsdist = True
usedevelop = True
minversion = 1.8
envlist =
py27-dj{15,16,17,18,19}
py34-dj{17,18,19}
py35-dj{18,19}
py27-dj{18,19,110}
py34-dj{18,19,110}
py35-dj{18,19,110}

[testenv]
setenv =
Expand All @@ -14,9 +14,7 @@ changedir=idptest
usedevelop=true
deps=
-r{toxinidir}/requirements-dev.txt
dj15: https://github.com/django/django/archive/stable/1.5.x.tar.gz#egg=django
dj16: https://github.com/django/django/archive/stable/1.6.x.tar.gz#egg=django
dj17: https://github.com/django/django/archive/stable/1.7.x.tar.gz#egg=django
dj18: https://github.com/django/django/archive/stable/1.8.x.tar.gz#egg=django
dj19: https://github.com/django/django/archive/stable/1.9.x.tar.gz#egg=django
dj18: django~=1.8.0
dj19: django~=1.9.0
dj110: django~=1.10.0
commands=py.test {posargs}

0 comments on commit a785e3f

Please sign in to comment.