# HG changeset patch # User ymh # Date 1442422135 -7200 # Node ID 5dd16d301bc5f55c3f072bd9861e887d3fe37807 # Parent cec363af95e695cf1271f3b1aabed04862b347a4 correct syntax error, again diff -r cec363af95e6 -r 5dd16d301bc5 server/src/remie/apps.py --- a/server/src/remie/apps.py Wed Sep 16 18:41:18 2015 +0200 +++ b/server/src/remie/apps.py Wed Sep 16 18:48:55 2015 +0200 @@ -1,5 +1,4 @@ from django.apps import AppConfig -from cas import REMIE_verify_cas2 class RemieAppConfig(AppConfig): ''' diff -r cec363af95e6 -r 5dd16d301bc5 server/src/remie/cas.py --- a/server/src/remie/cas.py Wed Sep 16 18:41:18 2015 +0200 +++ b/server/src/remie/cas.py Wed Sep 16 18:48:55 2015 +0200 @@ -12,43 +12,43 @@ class CASClientRemie(CASClientV2): def verify_ticket(self, ticket): - """Verifies CAS 2.0+ XML-based authentication ticket.""" - try: - from xml.etree import ElementTree - except ImportError: - from elementtree import ElementTree + """Verifies CAS 2.0+ XML-based authentication ticket.""" + try: + from xml.etree import ElementTree + except ImportError: + from elementtree import ElementTree - user = None - pgtiou = None + user = None + pgtiou = None - params = [('ticket', ticket), ('service', self.service_url)] - if self.proxy_callback: - params.append(('pgtUrl', self.proxy_callback)) + params = [('ticket', ticket), ('service', self.service_url)] + if self.proxy_callback: + params.append(('pgtUrl', self.proxy_callback)) - url = (urllib_parse.urljoin(self.server_url, 'serviceValidate') + '?' + - urllib_parse.urlencode(params)) - page = urlopen(url) - try: - response = page.read() - logger.debug("Verify CAS response : ") - logger.debug(response) - tree = ElementTree.fromstring(response) - if tree[0].tag.endswith('authenticationSuccess'): - attributes = {} - for element in tree[0]: - if element.tag.endswith('user'): - user = element.text - elif element.tag.endswith('nom'): - attributes['lastname'] = element.text - elif element.tag.endswith('prenom'): - attributes['firstname'] = element.text - elif element.tag.endswith('proxyGrantingTicket'): - pgtiou = element.text - return user, attributes, pgtiou - else: - return None, None, None - finally: - page.close() + url = (urllib_parse.urljoin(self.server_url, 'serviceValidate') + '?' + + urllib_parse.urlencode(params)) + page = urlopen(url) + try: + response = page.read() + logger.debug("Verify CAS response : ") + logger.debug(response) + tree = ElementTree.fromstring(response) + if tree[0].tag.endswith('authenticationSuccess'): + attributes = {} + for element in tree[0]: + if element.tag.endswith('user'): + user = element.text + elif element.tag.endswith('nom'): + attributes['lastname'] = element.text + elif element.tag.endswith('prenom'): + attributes['firstname'] = element.text + elif element.tag.endswith('proxyGrantingTicket'): + pgtiou = element.text + return user, attributes, pgtiou + else: + return None, None, None + finally: + page.close() def get_or_create_user(self, username, attributes): """get or create a user