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, \
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
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