Commits

David Larlet  committed f314f01

Switching to uuid to generate random keys

  • Participants
  • Parent commits a31148e

Comments (0)

Files changed (1)

File oauth_provider/models.py

+import uuid
 import urllib
 import urlparse
 from time import time
         Used to generate random key/secret pairings.
         Use this after you've added the other data in place of save().
         """
-        key = generate_random(length=KEY_SIZE)
-        secret = generate_random(length=SECRET_SIZE)
-        while Consumer.objects.filter(models.Q(key__exact=key) | models.Q(secret__exact=secret)).count():
-            key = generate_random(length=KEY_SIZE)
-            secret = generate_random(length=SECRET_SIZE)
-        self.key = key
-        self.secret = secret
+        self.key = uuid.uuid4().hex
+        self.secret = generate_random(length=SECRET_SIZE)
         self.save()
 
 
         Used to generate random key/secret pairings. 
         Use this after you've added the other data in place of save(). 
         """
-        key = generate_random(length=KEY_SIZE)
-        secret = generate_random(length=SECRET_SIZE)
-        while Token.objects.filter(models.Q(key__exact=key) | models.Q(secret__exact=secret)).count():
-            key = generate_random(length=KEY_SIZE)
-            secret = generate_random(length=SECRET_SIZE)
-        self.key = key
-        self.secret = secret
+        self.key = uuid.uuid4().hex
+        self.secret = generate_random(length=SECRET_SIZE)
         self.save()
 
     def get_callback_url(self):