Skip to content

Commit 80ea798

Browse files
author
Ralf Schlatterbeck
committed
use idea from Eli Collins to use a list of deprecated password encoding schemes
1 parent 57b0d9d commit 80ea798

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

roundup/password.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ class Password(JournalPassword):
240240
"""
241241
#TODO: code to migrate from old password schemes.
242242

243-
known_schemes = [ "PBKDF2", "SHA", "MD5", "crypt", "plaintext" ]
243+
deprecated_schemes = ["SHA", "MD5", "crypt", "plaintext"]
244+
known_schemes = ["PBKDF2"] + deprecated_schemes
244245

245246
def __init__(self, plaintext=None, scheme=None, encrypted=None, strict=False):
246247
"""Call setPassword if plaintext is not None."""
@@ -259,7 +260,7 @@ def needs_migration(self):
259260
""" Password has insecure scheme or other insecure parameters
260261
and needs migration to new password scheme
261262
"""
262-
if self.scheme != 'PBKDF2':
263+
if self.scheme in self.deprecated_schemes:
263264
return True
264265
rounds, salt, raw_salt, digest = pbkdf2_unpack(self.password)
265266
if rounds < 1000:

test/test_cgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def testPasswordMigration(self):
431431
cl = self._make_client(form)
432432
# assume that the "best" algorithm is the first one and doesn't
433433
# need migration, all others should be migrated.
434-
for scheme in password.Password.known_schemes[1:]:
434+
for scheme in password.Password.deprecated_schemes:
435435
pw1 = password.Password('foo', scheme=scheme)
436436
self.assertEqual(pw1.needs_migration(), True)
437437
self.db.user.set(chef, password=pw1)

0 commit comments

Comments
 (0)