Repository navigation
Conversation
Add GOTRUE_PASSWORD_HASH_COMPUTE_POLICY, a JSON object validated against a JSON schema, that limits which password hashing algorithms the server will verify and the maximum cost parameters they may use (bcrypt cost, Argon2 memory/time/threads and variants, Firebase scrypt n/r/p). Once set it is an allowlist: an algorithm that is not mentioned is rejected. Unknown keys are ignored so policies written for newer versions still load. A stored hash outside the policy is rejected before any hashing is done and the request fails with the new password_reset_required error code (HTTP 400). Password sign-in and the password checks in PUT /user apply the policy. In a recovery session the same-password check skips a blocked hash so the reset can replace it. Also log a warning, with the user ID and hash parameters (never salts, hashes or keys), whenever a password is compared against a non-default hash. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
Adds
GOTRUE_PASSWORD_HASH_COMPUTE_POLICY, a single JSON value that limits which password hashing algorithms the server will verify and the maximum cost parameters they may use. A stored hash outside the policy fails the request with a new error code,password_reset_required(HTTP 400), telling the client to start a password reset.The goal is to keep sign-in latency predictable on all projects while keeping an industry-acceptable security level.
{ "bcrypt": { "max_cost": 10 }, "argon2": { "variants": ["argon2i", "argon2id"], "max_memory_kib": 2048, "max_time": 4, "max_threads": 1 }, "fbscrypt": { "max_memory_cost_log2": 14, "max_rounds": 8, "max_threads": 1 } }Behaviour
"bcrypt": {}allows it without limits,"disabled": truerejects it, and{}rejects every hash.User.Authenticatechecks the hash before any hashing work. It applies to password sign-in and the password checks inPUT /user. In a recovery session the same-password check skips a blocked hash so the reset can replace it. Outside a recovery session the user getspassword_reset_required.example.env.Notes for review
User.Authenticategains a policy argument. Callers and tests are updated.password_reset_requiredtells a caller who knows an email that the account exists and has a hash outside the policy. Verifying first would defeat the purpose of avoiding the work.Testing
go build,go vetand theinternal/confandinternal/cryptotests pass (policy table, schema accept and reject cases, env decoding, hash parameter extraction).internal/apiandinternal/modelssuites need a database and the local Postgres credentials were rejected. That includes the new token test forpassword_reset_required.🤖 Generated with Claude Code