mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
c8c4389a61
commit
93630d53c7
@ -92,6 +92,7 @@ class AuthController(object):
|
|||||||
self.secret = bytes(binascii.hexlify(os.urandom(random.randint(20,
|
self.secret = bytes(binascii.hexlify(os.urandom(random.randint(20,
|
||||||
30))))
|
30))))
|
||||||
self.cookie_name = 'android_workaround'
|
self.cookie_name = 'android_workaround'
|
||||||
|
self.key_order = random.choice(('%(t)s:%(s)s', '%(s)s:%(t)s'))
|
||||||
|
|
||||||
def hashit(self, raw):
|
def hashit(self, raw):
|
||||||
return hashlib.sha256(raw).hexdigest()
|
return hashlib.sha256(raw).hexdigest()
|
||||||
@ -121,7 +122,7 @@ class AuthController(object):
|
|||||||
hashe of the timestamp and the server secret.
|
hashe of the timestamp and the server secret.
|
||||||
'''
|
'''
|
||||||
timestamp = int(time.time()) if timestamp is None else timestamp
|
timestamp = int(time.time()) if timestamp is None else timestamp
|
||||||
key = self.hashit('%d:%s'%(timestamp, self.secret))
|
key = self.hashit(self.key_order%dict(t=timestamp, s=self.secret))
|
||||||
return '%d:%s'%(timestamp, key)
|
return '%d:%s'%(timestamp, key)
|
||||||
|
|
||||||
def is_valid(self, cookie):
|
def is_valid(self, cookie):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user