-
Notifications
You must be signed in to change notification settings - Fork 107
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: add changing user password route for htpasswd #2183
base: main
Are you sure you want to change the base?
Conversation
c987ffe
to
77652ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
||
username := userAc.GetUsername() | ||
if username == "" { | ||
resp.WriteHeader(http.StatusNotFound) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to my previous comment: https://github.com/project-zot/zot/pull/2183/files#r1466598996
b79b823
to
46fdc8c
Compare
pkg/api/htpasswd.go
Outdated
return fmt.Errorf("error occurred while replacing htpasswd file with new file: %w", err) | ||
} | ||
|
||
err = os.WriteFile(hc.filepath, output, constants.DefaultDirPerms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be needed, right, or am I missing something?
you first write in tmpfile then you rename it to hc.filepath, that should be enough.
pkg/api/htpasswd.go
Outdated
return fmt.Errorf("error occurred while encrypting new password: %w", err) | ||
} | ||
|
||
file, err := os.ReadFile(hc.filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a lock to block other users changing their passwords from reading/writing the file at the same time, and only one of the password changes ending up in the file.
63df109
to
5f7370c
Compare
@@ -19,6 +19,7 @@ const ( | |||
LoginPath = AppNamespacePath + "/auth/login" | |||
LogoutPath = AppNamespacePath + "/auth/logout" | |||
APIKeyPath = AppNamespacePath + "/auth/apikey" | |||
ChangePasswordPath = AppNamespacePath + "/auth/change_password" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"chpasswd"
Cases to take care of:
|
Signed-off-by: onidoru <[email protected]>
Signed-off-by: onidoru <[email protected]>
Signed-off-by: Nikita Kotikov <[email protected]>
Signed-off-by: onidoru <[email protected]>
5f7370c
to
bf5bbee
Compare
What type of PR is this?
feature
Which issue does this PR fix:
It adds a feature of changing user password for htpasswd-file authentication.
What does this PR do / Why do we need it:
Issue: #702
Testing done on this change:
Unit testing.
Will this break upgrades or downgrades?
No.
Does this PR introduce any user-facing change?:
No.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.