Skip to content

Commit

Permalink
☢️ bug: decrease password length limit to 128 characters (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored May 24, 2024
1 parent b351533 commit c69ccbf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions backend/auth/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func ValidatePassword(password string) error {
errs = append(errs, "must be at least 8 characters long")
}

if len(password) > 128 { // see https://github.com/OWASP/ASVS/issues/756
errs = append(errs, "must be at most 128 characters long")
}

if !hasDigit(password) {
errs = append(errs, "must contain at least one digit")
}
Expand Down
4 changes: 2 additions & 2 deletions backend/entities/auth/base/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type VerifyEmailRequestBody struct {

type VerifyPasswordResetTokenRequestBody struct {
Token string `json:"token" validate:"required"`
NewPassword string `json:"new_password" validate:"required,min=8,password"`
VerifyNewPassword string `json:"verify_new_password" validate:"required,min=8,password,eqfield=NewPassword"`
NewPassword string `json:"new_password" validate:"required"` // MARK: must be validated manually
VerifyNewPassword string `json:"verify_new_password" validate:"required,eqfield=NewPassword"` // MARK: must be validated manually
}

type EmailRequestBody struct {
Expand Down
6 changes: 3 additions & 3 deletions backend/entities/auth/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package auth

type LoginResponseBody struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,max=255"` // MARK: must be validated manually
Password string `json:"password" validate:"required"` // MARK: must be validated manually
}

type UpdatePasswordRequestBody struct {
OldPassword string `json:"old_password" validate:"required,max=255"` // MARK: must be validated manually
NewPassword string `json:"new_password" validate:"required,not_equal_if_not_empty=OldPassword,max=255"` // MARK: must be validated manually
OldPassword string `json:"old_password" validate:"required"` // MARK: must be validated manually
NewPassword string `json:"new_password" validate:"required,not_equal_if_not_empty=OldPassword"` // MARK: must be validated manually
}

type RefreshTokenRequestBody struct {
Expand Down

0 comments on commit c69ccbf

Please sign in to comment.