Repository navigation
Conversation
Authenticate replaced u.EncryptedPassword with a fresh default-cost hash of the submitted password whenever the stored bcrypt cost was above the default or at the minimum. The sign-in handler never saves that value (the only write is the DB-encryption re-encryption path, which regenerates the hash itself), so the rehash had no durable effect. It also ran regardless of whether the password matched, leaving the in-memory user holding a hash of a possibly wrong password. Remove the rehash and keep the parse-error behaviour for malformed stored hashes. Update TestAuthenticate to assert that the stored hash is left untouched for both correct and incorrect passwords. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes the block in
User.Authenticatethat regenerated a default-cost bcrypt hash when the stored cost was above the default (10) or at the minimum.Why
u.EncryptedPasswordon the in-memory user. The sign-in handler never saves that value. The one write (ReEncryptPassword) runs only on the DB-encryption path, which regenerates the hash itself.Authenticatetakes atxthat it never uses, which suggests the rehash was meant to be saved and was not (introduced in feat: addpassword_hashandidfields to admin create user #1641).Stored hashes are not changed by this PR: before and after, a high-cost bcrypt hash stays as it is in the database.
Behaviour kept
A stored hash that is neither Argon2 nor Firebase scrypt and cannot be parsed by
bcrypt.Coststill makesAuthenticatereturn an error.Tests
TestAuthenticatenow asserts that the stored hash is untouched after both a wrong and a correct password, for cost 10 and cost 11.Not run locally: the models tests need a database and the local Postgres credentials were rejected. Built and vetted only.
🤖 Generated with Claude Code