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

chore: disbale public registration by default #764

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

elrrrrrrr
Copy link
Member

@elrrrrrrr elrrrrrrr commented Feb 27, 2025

The 'allowPublicRegistration' is enabled by default, which my cause unexpected users registering arbitrarily

  1. ⚙ Modify the default configuration 'allowPublicRegistration' to 'false'`

目前默认开启了 allowPublicRegistration 配置,公网部署可能会导致预期外的用户任意注册

  1. ⚙ 修改默认配置 allowPublicRegistrationfalse

Summary by CodeRabbit

  • New Features

    • Public registration can now be enabled through a new configuration option, allowing for more flexible user onboarding.
  • Bug Fixes

    • Updated the configuration to disallow public registration by default, ensuring only administrators can log in unless changed.
  • Documentation

    • Added an informational note in the developer documentation regarding public registration settings.
  • Tests

    • Introduced a setup method to enable public registration before each test case runs.

@elrrrrrrr elrrrrrrr requested a review from fengmk2 February 27, 2025 07:20
@elrrrrrrr elrrrrrrr added the enhancement New feature or request label Feb 27, 2025
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Walkthrough

This pull request modifies the public registration configuration. It introduces a new option allowPublicRegistration in the documentation (INTEGRATE.md) but updates the configuration file (config/config.default.ts) to set this property from true to false, disallowing public registration. An additional explanatory note is added in DEVELOPER.md, and a new method allowPublicRegistration() is introduced in the test utility to facilitate testing. The overall structure and control flow remain unchanged.

Changes

File Summary
INTEGRATE.md Added a new configuration option allowPublicRegistration set to true in documentation.
config/config.default.ts Updated the allowPublicRegistration property within the cnpmcoreConfig from true to false.
DEVELOPER.md Added an informational line regarding public registration in the "登录和测试发包" section.
test/.setup.ts Added invocation of TestUtil.allowPublicRegistration() in the beforeEach setup function.
test/TestUtil.ts Introduced a new static method allowPublicRegistration() in the TestUtil class.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant R as Registration Module
    participant C as Config
    U->>R: Submit Registration
    R->>C: Check allowPublicRegistration flag
    C-->>R: Return false
    R->>U: Deny registration request
Loading

Poem

I'm a rabbit with a code delight,
Hopping through changes in the night.
From true to false the flag did swing,
No public signups now take wing.
Carrots and code, a perfect bite—
Cheers to changes that keep things tight!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/.setup.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eggache".

(The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eggache@latest --save-dev

The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

test/TestUtil.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eggache".

(The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eggache@latest --save-dev

The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@fengmk2
Copy link
Member

fengmk2 commented Feb 27, 2025

涉及注册的单测估计都需要全局 mock 一下

@elrrrrrrr elrrrrrrr marked this pull request as draft February 27, 2025 07:43
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.43%. Comparing base (3054577) to head (3691919).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #764   +/-   ##
=======================================
  Coverage   96.43%   96.43%           
=======================================
  Files         192      192           
  Lines       19306    19306           
  Branches     2526     2526           
=======================================
  Hits        18618    18618           
  Misses        688      688           

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

@elrrrrrrr elrrrrrrr marked this pull request as ready for review February 27, 2025 13:03
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: 0

🧹 Nitpick comments (1)
test/TestUtil.ts (1)

136-138: Static method implementation looks good, but consider a small refactor.

The new allowPublicRegistration() method correctly sets the configuration flag to enable public registration for testing purposes. This is essential for test compatibility with the changed default setting.

Consider using the class name instead of this in the static method to improve clarity:

static allowPublicRegistration() {
-  this.app.config.cnpmcore.allowPublicRegistration = true;
+  TestUtil.app.config.cnpmcore.allowPublicRegistration = true;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 136-136: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 137-137: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 78f1ac0 and 3691919.

📒 Files selected for processing (4)
  • DEVELOPER.md (1 hunks)
  • INTEGRATE.md (1 hunks)
  • test/.setup.ts (1 hunks)
  • test/TestUtil.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • INTEGRATE.md
🧰 Additional context used
🪛 Biome (1.9.4)
test/TestUtil.ts

[error] 136-136: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 137-137: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

🔇 Additional comments (2)
test/.setup.ts (1)

8-8: Integration of the test environment with new registration policy looks good.

The addition of TestUtil.allowPublicRegistration() in the test setup ensures that all existing tests continue to work despite the default configuration change. This is a necessary adjustment given that public registration is now disabled by default.

DEVELOPER.md (1)

76-78: Documentation update provides clear guidance on the new default setting.

This addition effectively informs users about the new security policy where public registration is disabled by default, and provides instructions on how to enable it if needed. This aligns well with the PR's objective to enhance security by preventing arbitrary user registrations.

@fengmk2 fengmk2 merged commit 1922bf2 into master Feb 28, 2025
18 of 19 checks passed
@fengmk2 fengmk2 deleted the chore-public-registration branch February 28, 2025 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants