lastuser
lastuser copied to clipboard
Switch from md5sum to sha256
The UserEmail and UserEmailClaim fields store a md5sum hash with a unique constraint. However, md5sum is not safe anymore and a (small) risk of collision exists. We need to use sha256 instead.
However, md5sum is still required for external services like Gravatar, so we can't just remove it. We need to instead:
- Add sha256 column, populate it, change it to a required field with unique constraint (migration)
- Remove the unique constraint on md5sum, using just an index now, and
- Update code everywhere to use sha256 instead of md5sum.
To ensure old email verify and reset links continue working, the two views need to look for a match in both columns. The hashes have different lengths (IIRC) so there's no chance of a mismatch.