cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Feature: Forgot password

Open vishesh92 opened this issue 1 year ago • 14 comments

Description

This PR adds the functionality to reset password for a user by email.

8 Global settings:

Category Type Name Default value Description Dynamic
Advanced Long password.reset.ttl 30 Password reset ttl in minutes Yes
Advanced String password.reset.email.sender null Password reset email sender Yes
Advanced String password.reset.smtp.host null Password reset smtp host No
Advanced Integer password.reset.smtp.port 25 Password reset smtp port No
Advanced Boolean password.reset.smtp.useAuth False Use auth for smtp in Password reset No
Advanced String password.reset.smtp.username null Password reset smtp username No
Secure String password.reset.smtp.password null Password reset smtp password No
Advanced String password.reset.mail.template Hello {{username}}!\nYou have requested to reset your password. Please click the following link to reset your password:\n{{{reset_link}}}\nIf you did not request a password reset, please ignore this email.\n\nRegards,\nThe CloudStack Team Password reset mail template. This uses mustache template engine. Available variables are: username, firstName, lastName, resetLink, token Yes

2 new APIs:

  1. Command: forgotPassword Params: username, domain Details: Sends an email to the user with a token which can be used to reset the password using resetPassword command.
  2. Command: resetPassword Params: username, domain, token, password Details: Resets the password for the user using the token generated via forgotPassword command.

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [x] Minor

Screenshots (if appropriate):

How Has This Been Tested?

  1. Setup a mailserver or for testing purposes use the below command to setup maildev using docker
docker run -d -p 1080:1080 -p 1025:1025 maildev/maildev
  1. Update the above global settings to point the smtp host to the above docker container and restart the management server.
  2. Ensure an email is set for the test user
  3. In UI, click on forgot password and enter details.
  4. maildev runs a web ui to view all emails being sent. Open maildev's UI which is running on port 1080 and see if there are any emails.
  5. There should be an email from cloudstack to reset the password for the user. Click on the link in the email to reset the password or copy the token.
  6. Open the link in the email or navigate to {ACS MS}/user/resetPassword on the UI.
  7. Enter the details along with token from the email. Set the new password.
  8. Try login with the newly set password.

How did you try to break this feature and the system with this change?

vishesh92 avatar Aug 09 '24 09:08 vishesh92

Codecov Report

Attention: Patch coverage is 28.30769% with 233 lines in your changes missing coverage. Please review.

Project coverage is 15.76%. Comparing base (8c8d115) to head (b3ffbf3). Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
.../cloudstack/user/UserPasswordResetManagerImpl.java 41.84% 79 Missing and 3 partials :warning:
.../auth/DefaultResetPasswordAPIAuthenticatorCmd.java 0.00% 69 Missing :warning:
...auth/DefaultForgotPasswordAPIAuthenticatorCmd.java 0.00% 63 Missing :warning:
server/src/main/java/com/cloud/api/ApiServer.java 60.60% 12 Missing and 1 partial :warning:
...m/cloud/api/auth/APIAuthenticationManagerImpl.java 0.00% 3 Missing :warning:
...ma/src/main/java/com/cloud/user/UserAccountVO.java 0.00% 2 Missing :warning:
...c/main/java/com/cloud/user/AccountManagerImpl.java 80.00% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##               main    #9509     +/-   ##
===========================================
  Coverage     15.76%   15.76%             
- Complexity    12510    12524     +14     
===========================================
  Files          5621     5627      +6     
  Lines        491469   491884    +415     
  Branches      62967    60293   -2674     
===========================================
+ Hits          77460    77544     +84     
- Misses       405553   405878    +325     
- Partials       8456     8462      +6     
Flag Coverage Δ
uitests 4.03% <ø> (-0.02%) :arrow_down:
unittests 16.58% <28.30%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 09 '24 09:08 codecov[bot]

@blueorangutan package

vishesh92 avatar Aug 13 '24 08:08 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 13 '24 08:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10631

blueorangutan avatar Aug 13 '24 09:08 blueorangutan

@blueorangutan test

vishesh92 avatar Aug 13 '24 10:08 vishesh92

@vishesh92 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

blueorangutan avatar Aug 13 '24 10:08 blueorangutan

[SF] Trillian test result (tid-11068) Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 53619 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9509-t11068-kvm-ol8.zip Smoke tests completed. 138 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_redundant_vpc_site2site_vpn Failure 457.46 test_vpc_vpn.py
test_01_vpc_site2site_vpn Failure 320.12 test_vpc_vpn.py

blueorangutan avatar Aug 14 '24 01:08 blueorangutan

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Aug 20 '24 10:08 github-actions[bot]

@blueorangutan package

vishesh92 avatar Aug 23 '24 06:08 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 23 '24 06:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10773

blueorangutan avatar Aug 23 '24 07:08 blueorangutan

@blueorangutan package

vishesh92 avatar Aug 27 '24 16:08 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 27 '24 16:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10828

blueorangutan avatar Aug 27 '24 18:08 blueorangutan

@blueorangutan package

vishesh92 avatar Aug 30 '24 08:08 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 30 '24 08:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10878

blueorangutan avatar Aug 30 '24 09:08 blueorangutan

@blueorangutan package

vishesh92 avatar Sep 03 '24 07:09 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Sep 03 '24 07:09 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10925

blueorangutan avatar Sep 03 '24 09:09 blueorangutan

@blueorangutan package

vishesh92 avatar Sep 04 '24 12:09 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Sep 04 '24 12:09 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10963

blueorangutan avatar Sep 04 '24 14:09 blueorangutan

@blueorangutan package

vishesh92 avatar Sep 04 '24 15:09 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Sep 04 '24 15:09 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10966

blueorangutan avatar Sep 04 '24 16:09 blueorangutan

@blueorangutan package

vishesh92 avatar Sep 04 '24 22:09 vishesh92

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Sep 04 '24 22:09 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10970

blueorangutan avatar Sep 04 '24 23:09 blueorangutan

@blueorangutan package

vishesh92 avatar Sep 05 '24 10:09 vishesh92