Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.dll
*.so
*.dylib
/fix

# ---- Cookie / secret files (NEVER commit) ----
vc.jar
Expand Down
4 changes: 2 additions & 2 deletions cmd/vocat/bootstrap_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func runBootstrapAdmin(args []string) error {
return fmt.Errorf("read password: %w", err)
}
password = strings.TrimSuffix(strings.TrimSuffix(password, "\n"), "\r")
if len(password) < 12 || len(password) > 1024 {
return errors.New("bootstrap password must contain between 12 and 1024 characters")
if len(password) < 6 || len(password) > 1024 {
return errors.New("bootstrap password must contain between 6 and 1024 characters")
}
adminUsername := strings.TrimSpace(*username)
if len(adminUsername) < 1 || len(adminUsername) > 64 || strings.ContainsAny(adminUsername, "\r\n\t") {
Expand Down
2 changes: 1 addition & 1 deletion cmd/vocat/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (m *menu) msg(key string) string {
"prompt": {"请选择: ", "Select: "},
"invalid": {"无效选项,请重试。按 Ctrl+C 退出。", "Invalid choice, try again. Press Ctrl+C to exit."},
"new_username": {"新用户名(直接回车保留 %s): ", "New username (Enter to keep %s): "},
"new_pw": {"新密码 (至少 12 位): ", "New password (min 12 chars): "},
"new_pw": {"新密码 (至少 6 位): ", "New password (min 6 chars): "},
"confirm_pw": {"确认新密码: ", "Confirm new password: "},
"pw_changed": {"管理员账号密码已修改,现有 Web 会话已退出。", "Administrator credentials changed; existing Web sessions were signed out."},
"current_web_address": {"当前 Web 监听地址: %s", "Current Web listening address: %s"},
Expand Down
8 changes: 4 additions & 4 deletions internal/auth/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func (s *Service) ResetAdminCredentials(ctx context.Context, username string, pa
if len(username) < 1 || len(username) > 64 || strings.ContainsAny(username, "\r\n\t") {
return errors.New("administrator username must contain between 1 and 64 characters without control whitespace")
}
if len(password) < 12 || len(password) > 1024 {
return errors.New("administrator password must contain between 12 and 1024 characters")
if len(password) < 6 || len(password) > 1024 {
return errors.New("administrator password must contain between 6 and 1024 characters")
}
if err := s.EnsureAdmin(ctx, username, password); err != nil {
return fmt.Errorf("auth: reset administrator credentials: %w", err)
Expand Down Expand Up @@ -284,8 +284,8 @@ func (s *Service) ChangePassword(
currentPassword string,
newPassword string,
) error {
if len(newPassword) < 12 || len(newPassword) > 1024 {
return errors.New("new password must contain between 12 and 1024 characters")
if len(newPassword) < 6 || len(newPassword) > 1024 {
return errors.New("new password must contain between 6 and 1024 characters")
}
admin, err := s.store.AdminByUsername(ctx, strings.TrimSpace(username))
if errors.Is(err, store.ErrNotFound) {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/general_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (s *Server) handlePasswordChange(w http.ResponseWriter, r *http.Request) {
switch {
case errors.Is(err, auth.ErrInvalidCredentials):
writeError(w, http.StatusUnauthorized, "invalid_credentials", "current password is incorrect")
case strings.Contains(err.Error(), "between 12 and 1024"):
case strings.Contains(err.Error(), "between 6 and 1024"):
writeError(w, http.StatusBadRequest, "weak_password", err.Error())
case strings.Contains(err.Error(), "must differ"):
writeError(w, http.StatusBadRequest, "password_reused", err.Error())
Expand Down
Loading