mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-29 09:26:07 +01:00
...
This commit is contained in:
parent
c8c4389a61
commit
93630d53c7
1 changed files with 2 additions and 1 deletions
|
|
@ -92,6 +92,7 @@ def __init__(self, realm, users_dict):
|
|||
self.secret = bytes(binascii.hexlify(os.urandom(random.randint(20,
|
||||
30))))
|
||||
self.cookie_name = 'android_workaround'
|
||||
self.key_order = random.choice(('%(t)s:%(s)s', '%(s)s:%(t)s'))
|
||||
|
||||
def hashit(self, raw):
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
|
@ -121,7 +122,7 @@ def generate_cookie(self, timestamp=None):
|
|||
hashe of the timestamp and the server secret.
|
||||
'''
|
||||
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)
|
||||
|
||||
def is_valid(self, cookie):
|
||||
|
|
|
|||
Loading…
Reference in a new issue