Skip to content

Commit 1922bf2

Browse files
authored
chore: disbale public registration by default (#764)
> The 'allowPublicRegistration' is enabled by default, which my cause unexpected users registering arbitrarily 1. ⚙ Modify the default configuration 'allowPublicRegistration' to 'false'` ------------- > 目前默认开启了 `allowPublicRegistration` 配置,公网部署可能会导致预期外的用户任意注册 1. ⚙ 修改默认配置 `allowPublicRegistration` 为 `false` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 47da2f4 commit 1922bf2

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

DEVELOPER.md

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ curl -v http://127.0.0.1:7001
7373

7474
### 登录和测试发包
7575

76+
> cnpmcore 默认不开放注册,可以通过 `config.default.ts` 中的 `allowPublicRegistration` 配置开启,否则只有管理员可以登录
77+
78+
7679
注册 cnpmcore_admin 管理员
7780

7881
```bash

INTEGRATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export default () => {
9292
...cnpmcoreConfig,
9393
enableChangesStream: false,
9494
syncMode: SyncMode.all,
95+
allowPublicRegistration: true,
96+
// 放开注册配置
9597
};
9698
return config;
9799
}

config/config.default.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const cnpmcoreConfig: CnpmcoreConfig = {
4242
'@example',
4343
],
4444
allowPublishNonScopePackage: false,
45-
allowPublicRegistration: true,
45+
allowPublicRegistration: false,
4646
admins: {
4747
cnpmcore_admin: '[email protected]',
4848
},
@@ -221,4 +221,3 @@ export default (appInfo: EggAppConfig) => {
221221

222222
return config;
223223
};
224-

test/.setup.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ beforeEach(async () => {
55
// dont show console log on unittest by default
66
TestUtil.app.loggers.disableConsole();
77
await TestUtil.app.redis.flushdb('sync');
8+
TestUtil.allowPublicRegistration();
89
});
910

1011
afterEach(async () => {

test/TestUtil.ts

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export class TestUtil {
133133
return this._app;
134134
}
135135

136+
static allowPublicRegistration() {
137+
this.app.config.cnpmcore.allowPublicRegistration = true;
138+
}
139+
136140
static async rm(filepath: string) {
137141
try {
138142
await fs.unlink(filepath);

0 commit comments

Comments
 (0)