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 = { ...@@ -17,7 +17,6 @@ _DEFAULTS = {
} }
CAS_URI = 'http://www.yale.edu/tp/cas' CAS_URI = 'http://www.yale.edu/tp/cas'
NSMAP = {'cas': CAS_URI}
CAS = '{%s}' % CAS_URI CAS = '{%s}' % CAS_URI
for key, value in _DEFAULTS.iteritems(): for key, value in _DEFAULTS.iteritems():
......
...@@ -6,7 +6,7 @@ from urlparse import urljoin ...@@ -6,7 +6,7 @@ from urlparse import urljoin
from django.conf import settings from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django_cas.models import User, Tgt, PgtIOU from django_cas.models import User, Tgt, PgtIOU
from django_cas import CAS, NSMAP from django_cas import CAS
__all__ = ['CASBackend'] __all__ = ['CASBackend']
...@@ -56,9 +56,9 @@ def _verify_cas2(ticket, service): ...@@ -56,9 +56,9 @@ def _verify_cas2(ticket, service):
tree = ElementTree.fromstring(response) tree = ElementTree.fromstring(response)
page.close() page.close()
if tree.find(CAS + 'authenticationSuccess', namespaces=NSMAP) is not None: if tree.find(CAS + 'authenticationSuccess') is not None:
username = tree.find(CAS + 'authenticationSuccess/' + CAS + 'user', namespaces=NSMAP).text username = tree.find(CAS + 'authenticationSuccess/' + CAS + 'user').text
pgtIouIdElement = tree.find(CAS + 'authenticationSuccess/' + CAS + 'proxyGrantingTicket', namespaces=NSMAP); pgtIouIdElement = tree.find(CAS + 'authenticationSuccess/' + CAS + 'proxyGrantingTicket');
pgtIouId = pgtIouIdElement.text if pgtIouIdElement is not None else None pgtIouId = pgtIouIdElement.text if pgtIouIdElement is not None else None
if pgtIouId: if pgtIouId:
......
...@@ -8,7 +8,7 @@ from django_cas.exceptions import CasTicketException, CasConfigException ...@@ -8,7 +8,7 @@ from django_cas.exceptions import CasTicketException, CasConfigException
# Ed Crewe - add in signals to delete old tickets # Ed Crewe - add in signals to delete old tickets
from django.db.models.signals import post_save from django.db.models.signals import post_save
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django_cas import CAS, NSMAP from django_cas import CAS
class Tgt(models.Model): class Tgt(models.Model):
username = models.CharField(max_length = 255, unique = True) username = models.CharField(max_length = 255, unique = True)
...@@ -38,8 +38,8 @@ class Tgt(models.Model): ...@@ -38,8 +38,8 @@ class Tgt(models.Model):
try: try:
response = page.read() response = page.read()
tree = ElementTree.fromstring(response) tree = ElementTree.fromstring(response)
if tree.find(CAS + 'proxySuccess', namespaces=NSMAP) is not None: if tree.find(CAS + 'proxySuccess') is not None:
return tree.find(CAS + 'proxySuccess/' + CAS + 'proxyTicket' , namespaces=NSMAP).text return tree.find(CAS + 'proxySuccess/' + CAS + 'proxyTicket').text
else: else:
raise CasTicketException("Failed to get proxy ticket") raise CasTicketException("Failed to get proxy ticket")
finally: 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