Commit 4e64c503 by Ed Crewe

fix broken proxy auth check

parent 9d56c5a2
......@@ -49,27 +49,25 @@ def _verify_cas2(ticket, service):
urlencode(params))
page = urlopen(url)
try:
response = page.read()
tree = ElementTree.fromstring(response)
if tree[0].tag.endswith('authenticationSuccess'):
username = tree[0][0].text
if len(tree[0]) >= 2 and tree[0][1].tag.endswith('proxyGrantingTicket'):
pgtIou = PgtIOU.objects.get(pgtIou = tree[0][1].text)
try:
tgt = Tgt.objects.get(username = username)
tgt.tgt = pgtIou.tgt
tgt.save()
except ObjectDoesNotExist:
Tgt.objects.create(username = username, tgt = pgtIou.tgt)
pgtIou.delete()
return username
else:
return None
finally:
page.close()
response = page.read()
tree = ElementTree.fromstring(response)
page.close()
if tree[0].tag.endswith('authenticationSuccess'):
username = tree[0][0].text
if len(tree[0]) >= 2 and tree[0][1].tag.endswith('proxyGrantingTicket'):
pgtIou = PgtIOU.objects.get(pgtIou = tree[0][1].text)
try:
tgt = Tgt.objects.get(username = username)
tgt.tgt = pgtIou.tgt
tgt.save()
except ObjectDoesNotExist:
Tgt.objects.create(username = username, tgt = pgtIou.tgt)
pgtIou.delete()
return username
else:
return None
def verify_proxy_ticket(ticket, service):
......
......@@ -98,6 +98,7 @@ class TestCAS(unittest.TestCase):
print 'PASS: Got PT - %s' % pt
else:
print pt
#self.logout()
print ''
print 'Test SSO server login with proxy ticket'
......@@ -107,7 +108,8 @@ class TestCAS(unittest.TestCase):
print 'PASS: Got Success response for app %s using proxy %s' % (self.urls['app'], proxy)
else:
print 'FAIL: The proxy login to %s via %s has failed' % (self.urls['app'], self.urls['proxy'])
self.logout()
print ''
print 'Test direct proxy login'
print '-----------------------'
......
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