feat(auth): #66: replace regex password strength with entropy-based validation - #76
Merged
Conversation
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.
Closes #66
Summary
Replaces the hand-rolled regex-based
password_strengthvalidation with the go-password-validator library, which scores passwords by Shannon entropy instead of checking a fixed set of character classes.Changes
internal/features/auth/service.go— addedminPasswordEntropy = 60.0named constant;validatePasswordStrengthnow callspasswordvalidator.Validate(password, minPasswordEntropy). The fourregexp.MustCompileclass-counting checks are gone.internal/shared/errors/errors.go— addedErrWeakPasswordsentinel so a weak password surfaces a clear, actionable message instead of the generic "incomplete or invalid" error.internal/features/auth/service.go—Register/ResetPasswordreturnErrWeakPasswordwhen thepassword_strengthrule fails,ErrInvalidInputotherwise (viapasswordValidationError).frontend/src/lib/validations.ts— dropped the client-side class-counting regex checks (uppercase/lowercase/number/symbol) from the password schemas; keptmin 8. Strength is now backend-owned.go.mod/go.sum— addedgithub.com/wagslane/go-password-validator v0.3.0.Behavior
correcthorsebatterystaple, ~117 bits) are accepted.password, ~37 bits) are rejected with a clear message.min=8and thepassword_strengthvalidator glue are unchanged; the Wails-bound surface is untouched (nowailsjsregeneration needed).Verification
go build ./...,go vet ./...,gofmtcleannpm --prefix frontend run lint,npm --prefix frontend run type-check