-from __future__ import unicode_literals
-
from django.conf import settings
__all__ = []
-from __future__ import unicode_literals
-
from django.contrib import admin
from .models import *
-from __future__ import unicode_literals
-
from lxml import etree
import collections
-from __future__ import unicode_literals
-
from django import forms
from django.utils.translation import ugettext_lazy as _
contains the actual logic for determining which accounts are deleted.
"""
-from __future__ import print_function, unicode_literals
-
from django.core.management.base import NoArgsCommand
from django.conf import settings
-from __future__ import unicode_literals
-
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from random import Random
import string
-try:
- from urllib.parse import urlencode, urlparse, parse_qs, ParseResult
-except ImportError:
- from urllib import urlencode
- from urlparse import urlparse, ParseResult
- from urlparse import parse_qs
+from urllib.parse import urlencode, urlparse, parse_qs, ParseResult
+
__all__ = ['ServiceTicket', 'LoginTicket', 'ProxyGrantingTicket', 'ProxyTicket', 'ProxyGrantingTicketIOU']
-# -*- coding: utf-8 -*-
"""cas_provider.signals -- signal definitions for cas_provider
"""
-from __future__ import unicode_literals
-
from django import dispatch
-from __future__ import unicode_literals
-
from django.conf.urls import url
from cas_provider import views
-from __future__ import unicode_literals
-
import logging
logger = logging.getLogger('cas_provider.views')
-try:
- from urllib.error import HTTPError, URLError
- from urllib.parse import parse_qsl, urlencode, urlparse, urlsplit, urlunsplit
- from urllib.request import urlopen
-except ImportError:
- from urllib import urlencode
- from urllib2 import HTTPError, URLError, urlopen
- from urlparse import parse_qsl, urlparse, urlsplit, urlunsplit
+from urllib.error import HTTPError, URLError
+from urllib.parse import parse_qsl, urlencode, urlparse, urlsplit, urlunsplit
+from urllib.request import urlopen
from functools import wraps
-from django import VERSION
-from django.utils.decorators import available_attrs
from django.views.decorators.debug import sensitive_post_parameters
from django.views.decorators.cache import cache_control
from django.utils.cache import patch_cache_control
from . import signals
-if VERSION >= (1, 10):
- from django.urls import get_callable, reverse
- user_is_authenticated = lambda user: user.is_authenticated
-else:
- from django.core.urlresolvers import get_callable, reverse
- user_is_authenticated = lambda user: user.is_authenticated()
+from django.urls import get_callable, reverse
__all__ = ['login', 'validate', 'logout', 'service_validate']
Decorator that adds headers to a response so that it will
never be cached.
"""
- @wraps(view_func, assigned=available_attrs(view_func))
+ @wraps(view_func)
def _wrapped_view_func(request, *args, **kwargs):
response = view_func(request, *args, **kwargs)
patch_cache_control(response, no_cache=True,
else:
form = LoginForm(initial={'service': service})
- if user is not None and user_is_authenticated(user):
+ if user is not None and user.is_authenticated:
# We have an authenticated user.
if not user.is_active:
errors.append(_('This account is disabled. Please contact us if you feel it should be enabled again.'))
def logout(request, template_name='cas/logout.html',
auto_redirect=settings.CAS_AUTO_REDIRECT_AFTER_LOGOUT):
url = request.GET.get('url', None)
- if user_is_authenticated(request.user):
+ if request.user.is_authenticated:
for ticket in ServiceTicket.objects.filter(user=request.user):
ticket.delete()
auth_logout(request)
#!/usr/bin/env python
-from __future__ import unicode_literals
-
import os
import sys
-from __future__ import unicode_literals
-
-from django import VERSION
-
# Django settings for xxx project.
DEBUG = True
'django.contrib.messages.middleware.MessageMiddleware',
)
-# For Django < 1.10
-MIDDLEWARE_CLASSES = MIDDLEWARE
ROOT_URLCONF = 'simple.urls'
-from __future__ import unicode_literals
from io import StringIO
+from urllib.parse import urlparse, parse_qsl, parse_qs
+from urllib.request import install_opener
from xml import etree
from xml.etree import ElementTree
import cas_provider
from django.contrib.auth.models import User, UserManager
from django.test import TestCase
from django.conf import settings
-from django import VERSION
-
-
-try:
- from urllib.parse import urlparse, parse_qsl, parse_qs
- from urllib.request import install_opener
-except:
- from urlparse import urlparse, parse_qsl, parse_qs
- from urllib2 import install_opener
-
-
-if VERSION >= (1, 10):
- from django.urls import reverse
- user_is_anonymous = lambda user: user.is_anonymous
-else:
- from django.core.urlresolvers import reverse
- user_is_anonymous = lambda user: user.is_anonymous()
+from django.urls import reverse
class DummyOpener(object):
self.assertIsNotNone(proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket"))
proxyTicket_2 = proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket")
- proxyValidateResponse_3 = self.client.get(reverse('cas_proxy_validate'), {'ticket': proxyTicket_2.text, 'service': proxyTarget_2, 'pgtUrl': None})
+ proxyValidateResponse_3 = self.client.get(reverse('cas_proxy_validate'), {'ticket': proxyTicket_2.text, 'service': proxyTarget_2, 'pgtUrl': ''})
proxyValidateResponseXml_3 = ElementTree.parse(StringIO(proxyValidateResponse_3.content.decode('utf-8')))
auth_success_3 = proxyValidateResponseXml_3.find(CAS + 'authenticationSuccess')
self.assertEqual('root', user_3.text)
-
-
def test_succeessful_login(self):
response = self._login_user('root', '123')
self._validate_cas1(response, True)
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 302)
- self.assertTrue(response['location'].startswith('http://testserver/' if VERSION < (1, 9) else '/'))
+ self.assertTrue(response['location'].startswith('/'))
response = self.client.get(response['location'], follow=False)
self.assertIn(response.status_code, [302, 200])
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 200)
- self.assertEqual(user_is_anonymous(response.context['user']), True)
+ self.assertTrue(response.context['user'].is_anonymous)
def test_broken_pwd(self):
-from __future__ import unicode_literals
-
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView
long_description=read('README.rst'),
zip_safe=False,
install_requires=[
- 'Django>=1.5,<2.2',
+ 'Django>=1.10,<3.2',
'lxml',
],
classifiers = [
[tox]
envlist=clear,
- d18-py{27,34},
- d{19,110}-py{27,34,35},
- d111-py{27,34,35,36,37},
- d20-py{34,35,36,37},
+ d110-py{35},
+ d111-py{35,36,37},
+ d20-py{35,36,37},
d21-py{35,36,37},
+ d22-py{35,36,37,38,39}
+ d{30,31}-py{36,37,38,39}
stats
[testenv]
commands=coverage run --source=cas_provider --append --branch cas_provider_examples/manage.py test simple
deps=
- d18: Django>=1.8,<1.9
d19: Django>=1.9,<1.10
d110: Django>=1.10,<1.11
d111: Django>=1.11,<2.0
d20: Django>=2.0,<2.1
d21: Django>=2.1,<2.2
- d15,d16: https://bitbucket.org/andrewgodwin/south/get/e2c9102ee033.zip
+ d22: Django>=2.2,<3.0
+ d30: Django>=3.0,<3.1
+ d31: Django>=3.1,<3.2
coverage
usedevelop=True