Commit a4eec822 by Sebastian Annies

Merge pull request #2 from matthewwithanm/no-nsmap-patch

Don't use namespaces kwarg when calling find
parents 45151289 a92227c0
......@@ -17,7 +17,6 @@ _DEFAULTS = {
}
CAS_URI = 'http://www.yale.edu/tp/cas'
NSMAP = {'cas': CAS_URI}
CAS = '{%s}' % CAS_URI
for key, value in _DEFAULTS.iteritems():
......
......@@ -6,7 +6,7 @@ from urlparse import urljoin
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django_cas.models import User, Tgt, PgtIOU
from django_cas import CAS, NSMAP
from django_cas import CAS
__all__ = ['CASBackend']
......@@ -56,9 +56,9 @@ def _verify_cas2(ticket, service):
tree = ElementTree.fromstring(response)
page.close()
if tree.find(CAS + 'authenticationSuccess', namespaces=NSMAP) is not None:
username = tree.find(CAS + 'authenticationSuccess/' + CAS + 'user', namespaces=NSMAP).text
pgtIouIdElement = tree.find(CAS + 'authenticationSuccess/' + CAS + 'proxyGrantingTicket', namespaces=NSMAP);
if tree.find(CAS + 'authenticationSuccess') is not None:
username = tree.find(CAS + 'authenticationSuccess/' + CAS + 'user').text
pgtIouIdElement = tree.find(CAS + 'authenticationSuccess/' + CAS + 'proxyGrantingTicket');
pgtIouId = pgtIouIdElement.text if pgtIouIdElement is not None else None
if pgtIouId:
......
......@@ -8,7 +8,7 @@ from django_cas.exceptions import CasTicketException, CasConfigException
# Ed Crewe - add in signals to delete old tickets
from django.db.models.signals import post_save
from datetime import datetime, timedelta
from django_cas import CAS, NSMAP
from django_cas import CAS
class Tgt(models.Model):
username = models.CharField(max_length = 255, unique = True)
......@@ -38,8 +38,8 @@ class Tgt(models.Model):
try:
response = page.read()
tree = ElementTree.fromstring(response)
if tree.find(CAS + 'proxySuccess', namespaces=NSMAP) is not None:
return tree.find(CAS + 'proxySuccess/' + CAS + 'proxyTicket' , namespaces=NSMAP).text
if tree.find(CAS + 'proxySuccess') is not None:
return tree.find(CAS + 'proxySuccess/' + CAS + 'proxyTicket').text
else:
raise CasTicketException("Failed to get proxy ticket")
finally:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment