]> git.parisson.com Git - django-social-auth.git/commitdiff
Add 1.2.5 compatibility code. Refs #386
authorMatías Aguirre <matiasaguirre@gmail.com>
Thu, 5 Jul 2012 03:50:02 +0000 (00:50 -0300)
committerMatías Aguirre <matiasaguirre@gmail.com>
Thu, 5 Jul 2012 03:50:02 +0000 (00:50 -0300)
social_auth/backends/__init__.py
social_auth/utils.py

index a56ca5d957aa84e0970047a2df5515375af58e0b..aa8e2159cae659e9db7c1befa81b944ffd5f79a1 100644 (file)
@@ -23,11 +23,10 @@ from django.contrib.auth import authenticate
 from django.contrib.auth.backends import ModelBackend
 from django.utils import simplejson
 from django.utils.importlib import import_module
-from django.utils.crypto import constant_time_compare
 
 from social_auth.utils import setting, log, model_to_ctype, ctype_to_model, \
                               clean_partial_pipeline, url_add_parameters, \
-                              get_random_string
+                              get_random_string, constant_time_compare
 from social_auth.store import DjangoOpenIDStore
 from social_auth.backends.exceptions import StopPipeline, AuthException, \
                                             AuthFailed, AuthCanceled, \
index afc8177db58741cca8cec4adf22e61b4f39999f0..7c9a1f6220cf23f4836fb08d1eed37debc326a45 100644 (file)
@@ -35,9 +35,6 @@ except ImportError:  # django < 1.4
         return ''.join([random.choice(allowed_chars) for i in range(length)])
 
 
-get_random_string = random_string
-
-
 try:
     from django.utils.timezone import utc as django_utc
 except ImportError:  # django < 1.4
@@ -55,9 +52,23 @@ except ImportError:  # django < 1.4
         def dst(self, dt):
             return timedelta(0)
 
-    django_utc = None
+    django_utc = UTC()
+
 
+try:
+    from django.utils.crypto import constant_time_compare as ct_compare
+except ImportError:  # django < 1.4
+    def ct_compare(val1, val2):
+        if len(val1) != len(val2):
+            return False
+        result = 0
+        for x, y in zip(val1, val2):
+            result |= ord(x) ^ ord(y)
+        return result == 0
 
+
+get_random_string = random_string
+constant_time_compare = ct_compare
 utc = django_utc