correct syntax error, again
authorymh <ymh.work@gmail.com>
Wed, 16 Sep 2015 18:48:55 +0200
changeset 136 5dd16d301bc5
parent 135 cec363af95e6
child 137 f06cfe346ea9
correct syntax error, again
server/src/remie/apps.py
server/src/remie/cas.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):
     '''
--- 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