Skip to content

Commit d32ddb5

Browse files
committed
fix: add zxcvbn-go dependency
1 parent 70a1eab commit d32ddb5

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ require (
6565
github.com/multiformats/go-multistream v0.6.0 // indirect
6666
github.com/multiformats/go-varint v0.0.7 // indirect
6767
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
68+
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
6869
github.com/onsi/ginkgo/v2 v2.22.2 // indirect
6970
github.com/opencontainers/runtime-spec v1.2.0 // indirect
7071
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/n
218218
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
219219
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
220220
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
221+
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA=
222+
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8=
221223
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
222224
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
223225
github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
@@ -342,6 +344,7 @@ github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
342344
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
343345
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
344346
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
347+
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
345348
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
346349
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
347350
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=

internal/passphrase/validation.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type ValidationResult struct {
1717
// Following NIST and OWASP best practices:
1818
// - Minimum 12 characters (stronger than previous 8)
1919
// - At least 1 uppercase letter
20-
// - At least 1 lowercase letter
20+
// - At least 1 lowercase letter
2121
// - At least 1 digit
2222
// - At least 1 special character
2323
func Validate(passphrase string) ValidationResult {
@@ -35,7 +35,7 @@ func Validate(passphrase string) ValidationResult {
3535

3636
// Character set requirements
3737
hasUpper, hasLower, hasDigit, hasSpecial := false, false, false, false
38-
38+
3939
for _, char := range passphrase {
4040
switch {
4141
case unicode.IsUpper(char):
@@ -74,11 +74,11 @@ func GetErrorMessage(result ValidationResult) string {
7474
if result.Valid {
7575
return ""
7676
}
77-
77+
7878
if len(result.Errors) == 1 {
7979
return result.Errors[0]
8080
}
81-
81+
8282
return fmt.Sprintf("Passphrase requirements not met:\n• %s", strings.Join(result.Errors, "\n• "))
8383
}
8484

@@ -87,16 +87,16 @@ func GetStrength(passphrase string) string {
8787
if len(passphrase) < 8 {
8888
return "Very Weak"
8989
}
90-
90+
9191
result := Validate(passphrase)
9292
if !result.Valid {
9393
return "Weak"
9494
}
95-
95+
9696
// Count character types
9797
types := 0
9898
hasUpper, hasLower, hasDigit, hasSpecial := false, false, false, false
99-
99+
100100
for _, char := range passphrase {
101101
if unicode.IsUpper(char) && !hasUpper {
102102
hasUpper = true
@@ -115,7 +115,7 @@ func GetStrength(passphrase string) string {
115115
types++
116116
}
117117
}
118-
118+
119119
// Simple strength scoring based on length and character diversity
120120
if len(passphrase) >= 16 && types == 4 {
121121
return "Strong"
@@ -124,4 +124,4 @@ func GetStrength(passphrase string) string {
124124
} else {
125125
return "Weak"
126126
}
127-
}
127+
}

0 commit comments

Comments
 (0)