Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): validate password #779

Merged
merged 2 commits into from
Jul 21, 2023
Merged

Conversation

WaterLemons2k
Copy link
Contributor

@WaterLemons2k WaterLemons2k commented Jul 21, 2023

What does this PR do?

Use go-password-validator to checks that the password meets the minimum password requirements.

Fixes #778.

Motivation

#778

Additional Notes

https://github.com/wagslane/go-password-validator
https://github.com/coder/coder/blob/0c73164f15da870f0c71d842844a95e4fb73304e/coderd/userpassword/userpassword.go#L128

Known issue: After upgrading from a version that does not validate passwords, weak passwords may not be saved even if the password remains the same.

Solution:

-	// 如果密码不为空则检查是否够强
-	if passwordNew != "" {
+	// 如果更改了密码且不为空则检查是否够强
+	if conf.Password != passwordNew && passwordNew != "" {

@WaterLemons2k
Copy link
Contributor Author

WaterLemons2k commented Jul 21, 2023

另外,目前如果密码不够强返回的错误说明是英文的,要不要基于 passwordvalidator.Validate() 修改以返回中文错误说明?

@jeessy2
Copy link
Owner

jeessy2 commented Jul 21, 2023

可以返回中文。minEntropy 60得不得高了点,选个适中的

web/save.go Outdated Show resolved Hide resolved
@jeessy2 jeessy2 marked this pull request as ready for review July 21, 2023 06:36
Copy link
Owner

@jeessy2 jeessy2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeessy2 jeessy2 merged commit 6bc09d7 into jeessy2:master Jul 21, 2023
@WaterLemons2k WaterLemons2k deleted the password branch July 21, 2023 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

账号密码必填?
2 participants