hydra-init: upgrade passwords to Argon2 on startup

This commit is contained in:
Graham Christensen
2021-04-16 12:09:30 -04:00
parent 79b0ddc27d
commit 05636de7d2
2 changed files with 77 additions and 0 deletions

View File

@ -72,3 +72,12 @@ for (my $n = $schemaVersion; $n < $maxSchemaVersion; $n++) {
};
die "schema upgrade failed: $@\n" if $@;
}
my @usersWithSha1s = $db->resultset('Users')->search(\['LENGTH(password) = 40 AND password ~ \'^[0-9a-f]{40}$\'']);
if (scalar(@usersWithSha1s) > 0) {
print STDERR "upgrading user passwords from sha1\n";
for my $user (@usersWithSha1s) {
print STDERR " * " . $user->username . "\n";
$user->setPassword($user->password);
}
}