Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
sudo: false
python:
- "2.7"
- "3.5"
env:
- DJANGO="Django>=1.8.0,<1.9.0"
- DJANGO="Django>=1.9.0,<1.10.0"
Expand Down
43 changes: 32 additions & 11 deletions djangowind/auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
from __future__ import unicode_literals

from django.conf import settings
from django.contrib.auth.models import User, Group
import urllib
import urllib2

try:
from urllib.request import Request
except ImportError:
from urllib2 import Request

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen

try:
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode

try:
from urllib.parse import quote
except ImportError:
from urllib2 import quote

from django.core.exceptions import ImproperlyConfigured
from warnings import warn
from django_statsd.clients import statsd
Expand All @@ -22,7 +43,7 @@ def validate_wind_ticket(ticketid):
if hasattr(settings, 'WIND_BASE'):
wind_base = getattr(settings, 'WIND_BASE')
uri = wind_base + "validate?ticketid=%s" % ticketid
response = urllib.urlopen(uri).read()
response = urlopen(uri).read()
lines = response.split("\n")
if lines[0] == "yes":
statsd.incr('djangowind.validate_wind_ticket.success')
Expand Down Expand Up @@ -51,8 +72,8 @@ def validate_cas2_ticket(ticketid, url):
cas_base = getattr(settings, 'CAS_BASE')
uri = cas_base + "cas/serviceValidate?ticket=%s&service=%s" % (
ticketid,
urllib2.quote(url))
response = urllib.urlopen(uri).read()
quote(url))
response = urlopen(uri).read()
try:
dom = parseString(response)
if dom.documentElement.nodeName != 'cas:serviceResponse':
Expand Down Expand Up @@ -138,12 +159,12 @@ def validate_saml_ticket(ticketid, url):
'connection': 'keep-alive',
'content-type': 'text/xml'}
params = {'TARGET': url}
uri = cas_base + "cas/samlValidate" + '?' + urllib.urlencode(params)
url = urllib2.Request(uri, '', headers)
uri = cas_base + "cas/samlValidate" + '?' + urlencode(params)
request = Request(uri, '', headers)
data = get_saml_assertion(ticketid)
url.add_data(data)
request.data = data

page = urllib2.urlopen(url)
page = urlopen(request)
response = page.read()
try:
user = None
Expand Down Expand Up @@ -240,10 +261,10 @@ def load_handler(self, path):
module, attr = path[:i], path[i + 1:]
try:
mod = __import__(module, {}, {}, [attr])
except ImportError, e:
except ImportError as e:
raise ImproperlyConfigured(
'Error importing wind handler %s: "%s"' % (module, e))
except ValueError, e:
except ValueError as e:
raise ImproperlyConfigured('Error importing wind handler.')
try:
cls = getattr(mod, attr)
Expand Down
2 changes: 2 additions & 0 deletions djangowind/context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.conf import settings
from django.contrib.auth.forms import AuthenticationForm

Expand Down
Loading