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

Add reset password button to ops project list #4910

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Add reset password button to ops project list #4910

merged 1 commit into from
Jun 26, 2024

Conversation

dgannon991
Copy link
Contributor

What this PR does / why we need it:
Adds a reset password button to the project list in the ops view

Which issue(s) this PR fixes:

Fixes #4844

Does this PR introduce a user-facing change?:
Yes, a new button and column in the ops list

  • How are users affected by this change: the OPs UI is updated
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Just pushing up a draft for this at the moment to get some early feedback. I'll have a look through to see how/if we're testing the ops side of things later, but wanted to provide an early view of the UI.

image

@dgannon991
Copy link
Contributor Author

@khanhtc1202 & @ffjlabo - forgot that it wouldn't notify you in draft mode :D Nothing urgent, just hoped to get some feedback on the UI before writing up the tests. Cheers!

@dgannon991 dgannon991 marked this pull request as ready for review May 12, 2024 18:20
@ffjlabo
Copy link
Member

ffjlabo commented May 13, 2024

@dgannon991
Thank you so much for the quick response!! The button UI is LGTM for me :)

Thanks to your PR, I noticed this action is extremely dangerous because the control plane operator might reset for other projects accidentally. 👀
It would be nice to prevent users from accidentally initializing static admins for other projects.

So, how about adding a confirmation screen?
e.g. the project list page -> reset password confirmation page -> success page

Reset password confirmation page like this↓ (the sentences are the draft, and I want more correct them 🙏 )

Reset Static Admin for the project XXX.
You must check the project name before you click the button.

"Reset button"

@khanhtc1202
Copy link
Member

@dgannon991 @ffjlabo
How about asking the user to reinstate the project name as part of the reset password confirmation page? (Cloud service like AWS use that method as re-check step if I remember correctly)

@dgannon991
Copy link
Contributor Author

I like the sound of that. I've got some down time over the next couple of days, so I'll give it a go and let you know :)

@ffjlabo
Copy link
Member

ffjlabo commented May 14, 2024

@dgannon991 @khanhtc1202

How about asking the user to reinstate the project name as part of the reset password confirmation page? (Cloud service like AWS use that method as re-check step if I remember correctly)

Thank you both 🙏 I agree with it!

@dgannon991
Copy link
Contributor Author

Hi Guys,
I've added a confirmation page, and you have to retype the project ID.
One note though, the user experience is not great when you get things wrong (due to the server just returning error responses instead of markup.) Are we happy with this, as the ops pages are for technical users?
Cheers!

@ffjlabo
Copy link
Member

ffjlabo commented May 17, 2024

@dgannon991
Thank you for the nice commitment :)
I also agree the ops pages are plain because these are for technical users.

[IMO] If possible, it would be nice to show the Reset page with the failed message, or the link to the Reset page.

Project Page
Cursor_と_localhost_9082_projects

Fail
Cursor_と_localhost_9082_projects_reset-password_ID_test

Succsess
localhost_9082_projects_reset-password_ID_test

@dgannon991
Copy link
Contributor Author

Absolutely. I'll give that a whirl over the weekend. Cheers for the continued feedback on this one guys :)

@dgannon991
Copy link
Contributor Author

Morning! I've updated this to show a nice error message on the confirmation page. Do let me know if it's too big and red! I looked at the material UI library we use in the normal frontend for inspiration, but it is the first think like it on the ops pages!

@ffjlabo
Copy link
Member

ffjlabo commented May 25, 2024

Hi @dgannon991
Sorry for the late reply. Currently doing the other task.
So plz wait a moment 🙏

@dgannon991
Copy link
Contributor Author

Hi @ffjlabo,

Not a problem at all, the other task looks mega! No rush from my side at all :)

D

Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 76.98413% with 29 lines in your changes missing coverage. Please review.

Project coverage is 22.24%. Comparing base (643b96b) to head (c52f1eb).
Report is 6 commits behind head on master.

Files Patch % Lines
pkg/app/ops/handler/handler_mock.go 57.50% 17 Missing ⚠️
pkg/app/ops/handler/handler.go 86.04% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4910      +/-   ##
==========================================
+ Coverage   22.05%   22.24%   +0.19%     
==========================================
  Files         519      520       +1     
  Lines       57247    57365     +118     
==========================================
+ Hits        12623    12763     +140     
+ Misses      43601    43575      -26     
- Partials     1023     1027       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dgannon991
Copy link
Contributor Author

Hi Guys,
Just working on the coverage now. I've brought it up, but I think it will now be easy to really get it much higher, so I'll have another go tomorrow night at getting it there :)
Cheers!
David

@dgannon991
Copy link
Contributor Author

Hi Guys,
Managed to get a few more tests written, and I've got pretty much everything I added covered. It does use gomock (which is a shame) but I couldn't think of a better way to test without actually creating a project store!
Let me know what you think!
D

@khanhtc1202
Copy link
Member

/review

Copy link
Contributor

PR Analysis

Main theme

"Enhancement"

PR summary

"The PR introduces enhancements to the password reset mechanism within a Go web application, including updated request handlers, a new interface for project updates, and two new HTML templates for the password reset process."

Type of PR

"Enhancement"

PR Feedback:

General suggestions

The PR introduces a new feature for resetting static admin passwords for projects. This includes backend handler implementation, logic to fetch and update project information, as well as frontend templates for the reset password confirmation and result pages. Overall, the code changes appear to correctly implement the new feature, but with some points that need addressing for error handling and server response consistency.

Code feedback

- relevant file: "pkg/app/ops/handler/handler.go"
  suggestion: |-
    To avoid executing unnecessary code when an error is detected, you should return early after writing an error response to the client. This is particularly applicable in the 'handleResetPassword' function where several paths write an error response but do not immediately return, potentially leading to further (and unnecessary) code execution.
    `important`
  relevant line: "+		http.Error(w, "not found", http.StatusNotFound)"

- relevant file: "pkg/app/ops/handler/handler.go"
  suggestion: |-
    Consider implementing rate limiting or CAPTCHA validation to protect the password reset endpoint from being abused by automated scripts or brute force attacks.
    `important`
  relevant line: "+func (h *Handler) handleResetPassword(w http.ResponseWriter, r *http.Request) {"

- relevant file: "pkg/app/ops/handler/handler.go"
  suggestion: |-
    For improved security practices, avoid using predictable patterns for randomly generated passwords and consider integrating a cryptographically secure password generator.
    `medium`
  relevant line: "+	password := model.GenerateRandomString(30)"

Security concerns:

"yes"
"While no direct security vulnerabilities such as SQL injection or XSS are introduced in this PR, it does add new endpoints that could be susceptible to abuse, such as brute force attacks on the password reset function. Recommendations have been provided to mitigate these risks."

khanhtc1202
khanhtc1202 previously approved these changes Jun 18, 2024
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

I checked the behavior, and it works as we expected. Thanks a lot, @dgannon991 👍
I left some nits, but they can mostly be fixed later by separated PRs.

LGTM 👍

@dgannon991
Copy link
Contributor Author

Hi Guys, more than happy to address these here if you'd like? LMK.

@Warashi Warashi self-requested a review June 19, 2024 01:11
Warashi
Warashi previously approved these changes Jun 19, 2024
Copy link
Contributor

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

I also checked the behavior, and it worked as expected 👍
I have no comments other than comments by @khanhtc1202
LGTM 👍

@khanhtc1202
Copy link
Member

Hi Guys, more than happy to address these here if you'd like? LMK.

@dgannon991 For sure, let's do as you want 👍

@Warashi
Copy link
Contributor

Warashi commented Jun 19, 2024

Thank you for saying that.
I dismissed my approval for this PR not to make this PR merge by mistake, but it does not mean the code is not good.

@Warashi Warashi dismissed their stale review June 19, 2024 02:19

not to make this PR merge by mistake, but it does not mean the code is not good

@dgannon991
Copy link
Contributor Author

Nice one! I’m AFK until Thursday night, but I’ll get it done Friday morning! Cheers all.

@dgannon991
Copy link
Contributor Author

Hi Guys,
The git history got a bit squirrely there, apologies. I rebased on my local master, but didn't realise it was stale! I'd definitely suggest a squash commit on this one!
I've made the changes, and run the tests, and things still look good. I'll stand everything up when I get a second tomorrow AM and give a final update :)
Cheers all.

Signed-off-by: David Gannon <19214156+dgannon991@users.noreply.github.com>
@dgannon991
Copy link
Contributor Author

Hi Guys,
This looks better now, removed all the silly extra commits! I've given it a run through and it all works as expected :)
Cheers!
David

@@ -305,6 +305,15 @@ func (x *Project) GetStaticAdminDisabled() bool {
return false
}

func (x *Project) GetStaticAdminUsername() string {
Copy link
Contributor

@Warashi Warashi Jun 25, 2024

Choose a reason for hiding this comment

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

This file is generated by protoc-gen-go, so please move this method to pkg/model/project.go file.

@Warashi
Copy link
Contributor

Warashi commented Jun 25, 2024

I checked the behavior, and it worked fine.
I commented nits. Please re-request a review or mention us in the comments when you resolve that.

@khanhtc1202 khanhtc1202 enabled auto-merge (squash) June 26, 2024 10:50
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

Thank you 💯

Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

Thank you!

@khanhtc1202 khanhtc1202 merged commit d4689bf into pipe-cd:master Jun 26, 2024
14 of 15 checks passed
@khanhtc1202 khanhtc1202 mentioned this pull request Jun 26, 2024
@dgannon991 dgannon991 deleted the feat/4844/reset-password-button branch June 26, 2024 21:02
@github-actions github-actions bot mentioned this pull request Jul 4, 2024
hungran pushed a commit to hungran/pipecd that referenced this pull request Jul 6, 2024
Signed-off-by: David Gannon <19214156+dgannon991@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check or reset the ID/PW of a project once registered when forgetting them
5 participants