-
Notifications
You must be signed in to change notification settings - Fork 902
fix: improve password validation flow #15132
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
Changes from 16 commits
b93dc6b
cf31dde
309d839
388a58b
f9cce4c
8a5e63f
8f695ab
c103559
dc46019
37072ee
b4b8b06
0efd24f
a6ee1cc
51b1e51
e2128e6
f37ef9e
36cadeb
175b4bf
f33eac2
2e0941b
3869dd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -437,6 +437,38 @@ func (api *API) postChangePasswordWithOneTimePasscode(rw http.ResponseWriter, r | |
} | ||
} | ||
|
||
// ValidateUserPassword validates the complexity of a user password and that it is secured enough. | ||
// | ||
// @Summary Validate user password | ||
// @ID validate-user-password | ||
// @Security CoderSessionToken | ||
// @Produce json | ||
// @Accept json | ||
// @Tags Authorization | ||
// @Param request body codersdk.ValidateUserPasswordRequest true "Validate user password request" | ||
// @Success 200 {object} codersdk.ValidateUserPasswordResponse | ||
// @Router /users/validate-password [post] | ||
func (*API) validateUserPassword(rw http.ResponseWriter, r *http.Request) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit about referring to all of this stuff as "user password" validation: the password is not yet attached to a user, so it's not a user password, it's just a password, so I'd expect it to be called |
||
var ( | ||
ctx = r.Context() | ||
valid = true | ||
) | ||
|
||
var req codersdk.ValidateUserPasswordRequest | ||
if !httpapi.Read(ctx, rw, r, &req) { | ||
return | ||
} | ||
|
||
err := userpassword.Validate(req.Password) | ||
if err != nil { | ||
valid = false | ||
defelmnq marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
httpapi.Write(ctx, rw, http.StatusOK, codersdk.ValidateUserPasswordResponse{ | ||
Valid: valid, | ||
}) | ||
} | ||
|
||
// Authenticates the user with an email and password. | ||
// | ||
// @Summary Log in user | ||
|
defelmnq marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.