Skip to content

* Hide password when registering or modifying users #5414

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

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

arrow1991
Copy link
Contributor

@arrow1991 arrow1991 commented Jun 25, 2025

What's the purpose of this PR

Passwords displayed in plain text pose security risks

Brief changelog

Follow this checklist to help us incorporate your contribution quickly and easily:

  • [√] Read the Contributing Guide before making this pull request.
  • [√] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • [√] Write necessary unit tests to verify the code.
  • [√] Run mvn clean test to make sure this pull request doesn't break anything.
  • [√] Update the CHANGES log.

Summary by CodeRabbit

  • New Features

    • Added password confirmation field during user creation and editing, with real-time validation to ensure passwords match.
    • Password input is now masked for improved privacy.
    • Error message displayed if passwords do not match, and submission is disabled until resolved.
  • Localization

    • Added English and Chinese translations for "Confirm Password" and "Passwords do not match" in the user management interface.
  • Documentation

    • Updated changelog to note password masking for user registration and modification.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 25, 2025
@@ -28,6 +28,7 @@ function UserController($scope, $window, $translate, toastr, AppUtil, UserServic
$scope.changeStatus = changeStatus
$scope.searchUsers = searchUsers
$scope.resetSearchUser = resetSearchUser
$scope.validatePwdMatch = validatePwdMatch
Copy link

Choose a reason for hiding this comment

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

Missing semicolon.

Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

Password handling in the user management interface was enhanced by adding a password confirmation field, client-side validation for matching passwords, and masking password inputs. Localization files were updated with new entries for these features, and the changelog documents the security-related update.

Changes

File(s) Change Summary
CHANGES.md Updated changelog to include security-related entry about hiding passwords during user registration/modification.
.../i18n/en.json
.../i18n/zh-CN.json
Added localization entries for "Confirm Password" and "Passwords do not match" in English and Chinese.
.../controller/UserController.js Added validatePwdMatch for password confirmation validation; updated createOrUpdateUser to enforce password match before submission.
.../user-manage.html Changed password input to masked type, added confirm password field, error message for mismatch, and updated submit button logic.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User as User
    participant UI as user-manage.html
    participant Ctrl as UserController.js

    User->>UI: Enter password and confirm password
    UI->>Ctrl: validatePwdMatch()
    Ctrl->>UI: Set pwdNotMatch flag

    alt Passwords do not match
        UI->>User: Show "Passwords do not match" error
        UI-->>Ctrl: Prevent form submission
    else Passwords match
        User->>UI: Click submit
        UI->>Ctrl: createOrUpdateUser()
        Ctrl->>Ctrl: validatePwdMatch()
        alt pwdNotMatch is true
            Ctrl-->>UI: Abort submission
        else
            Ctrl->>Server: Submit user data
        end
    end

Suggested labels

size:S, lgtm

Poem

In fields of code where passwords hide,
A rabbit hops with careful pride.
Two fields now dance, a match required—
If not, a warning is inspired!
With masked secrets safe from view,
This bunny cheers, “Well done, anew!”
🐇🔒


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3fa16c and cf8889b.

📒 Files selected for processing (5)
  • CHANGES.md (1 hunks)
  • apollo-portal/src/main/resources/static/i18n/en.json (1 hunks)
  • apollo-portal/src/main/resources/static/i18n/zh-CN.json (1 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/UserController.js (3 hunks)
  • apollo-portal/src/main/resources/static/user-manage.html (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apollo-portal/src/main/resources/static/i18n/en.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • CHANGES.md
  • apollo-portal/src/main/resources/static/i18n/zh-CN.json
  • apollo-portal/src/main/resources/static/user-manage.html
  • apollo-portal/src/main/resources/static/scripts/controller/UserController.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (8)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
apollo-portal/src/main/resources/static/scripts/controller/UserController.js (2)

31-31: Missing semicolon consistent with codebase style.

The missing semicolon follows the same pattern as previous review comments on this codebase.


89-94: Improve password validation logic.

The current validation only checks if password exists but doesn't validate confirmPassword presence. This could result in false validation when confirmPassword is undefined or empty.

 function validatePwdMatch() {
     $scope.pwdNotMatch = false
-    if ($scope.user.password && $scope.user.password != $scope.user.confirmPassword) {
+    if ($scope.user.password && $scope.user.confirmPassword && 
+        $scope.user.password !== $scope.user.confirmPassword) {
         $scope.pwdNotMatch = true
     }
 }

Also note the missing semicolons on lines 90 and 92, which is consistent with the existing codebase style issues flagged in previous reviews.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf0ad6d and d3fa16c.

📒 Files selected for processing (5)
  • CHANGES.md (1 hunks)
  • apollo-portal/src/main/resources/static/i18n/en.json (1 hunks)
  • apollo-portal/src/main/resources/static/i18n/zh-CN.json (1 hunks)
  • apollo-portal/src/main/resources/static/scripts/controller/UserController.js (3 hunks)
  • apollo-portal/src/main/resources/static/user-manage.html (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (8)
🔇 Additional comments (7)
apollo-portal/src/main/resources/static/i18n/zh-CN.json (1)

625-626: New keys look correct – please double-check for duplicates in the bundle

Translations are accurate and the naming convention (UserMange.*) stays consistent with the (unfortunate) historic typo.
Before merging, run the usual “duplicate-key” lint to be certain these two keys are not declared elsewhere in the file – the JSON is already >950 lines and easy to overlook.

apollo-portal/src/main/resources/static/i18n/en.json (1)

625-626: Strings added correctly, but verify usage spelling

The English strings are fine. Make sure the UI code references the exact keys UserMange.ConfirmPwd / UserMange.PwdNotMatch (including the original “Mange” typo); otherwise the labels will fall back to the key name.

apollo-portal/src/main/resources/static/user-manage.html (4)

134-134: Excellent security improvement!

Changing the password input type from "text" to "password" properly masks the password characters, preventing visual exposure during input.


135-138: Good UX for password validation feedback.

The conditional error message provides clear feedback when passwords don't match, improving user experience during form completion.


140-147: Well-implemented password confirmation field.

The password confirmation field follows consistent form structure and triggers validation on blur event for immediate feedback without being intrusive.


172-172: Proper form submission prevention.

The submit button correctly prevents submission when passwords don't match, ensuring data integrity before form submission.

apollo-portal/src/main/resources/static/scripts/controller/UserController.js (1)

115-118: Excellent placement of password validation.

The validation is correctly placed before user creation/update, ensuring passwords match before submission and providing proper early return to prevent invalid operations.

CHANGES.md Outdated
@@ -16,5 +16,6 @@ Apollo 2.5.0
* [Security: Prevent unauthorized access to other users' apps in /apps/by-owner endpoint](https://github.com/apolloconfig/apollo/pull/5396)
* [Fix: Bump h2database and snakeyaml version](https://github.com/apolloconfig/apollo/pull/5406)
* [Bugfix: Correct permission target format to appId+env+namespace/cluster](https://github.com/apolloconfig/apollo/pull/5407)
* [Security: Hide password when registering or modifying users](https://github.com/apolloconfig/apollo/pull/5413)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect PR number in changelog entry

The PR referenced in the changelog (#5413) does not match the current PR (#5414).
Fix the link to avoid pointing users at the wrong discussion.

-* [Security: Hide password when registering or modifying users](https://github.com/apolloconfig/apollo/pull/5413)
+* [Security: Hide password when registering or modifying users](https://github.com/apolloconfig/apollo/pull/5414)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* [Security: Hide password when registering or modifying users](https://github.com/apolloconfig/apollo/pull/5413)
* [Security: Hide password when registering or modifying users](https://github.com/apolloconfig/apollo/pull/5414)
🤖 Prompt for AI Agents
In CHANGES.md at line 19, the PR number in the changelog entry is incorrect; it
references #5413 instead of the correct PR #5414. Update the PR link to use
#5414 so it points to the correct pull request discussion.

Copy link
Member

@hezhangjian hezhangjian left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 26, 2025
@nobodyiam nobodyiam merged commit f4bdc04 into apolloconfig:master Jun 27, 2025
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants