keep salting generated tokens

all the savings are in rounds, but keep salt because it still prevents the ability to hash a token once and check it against the whole db
This commit is contained in:
Min RK
2017-08-06 14:16:47 +02:00
parent a27765f7d5
commit 25d19732e0
2 changed files with 5 additions and 2 deletions

View File

@@ -243,7 +243,7 @@ class Hashed(object):
# values to use for internally generated tokens,
# which have good entropy as UUIDs
generated = True
generated_salt_bytes = b''
generated_salt_bytes = 8
generated_rounds = 1
@property

View File

@@ -67,7 +67,10 @@ def test_tokens(db):
assert found.match(token)
assert found.user is user
assert found.service is None
assert found.hashed.startswith('%s:1::' % orm.APIToken.algorithm)
algo, rounds, salt, checksum = found.hashed.split(':')
assert algo == orm.APIToken.algorithm
assert rounds == '1'
assert len(salt) == orm.APIToken.generated_salt_bytes * 2
found = orm.APIToken.find(db, 'something else')
assert found is None