Skip to content

Commit 6763eaa

Browse files
committed
feat: control web UI access via shouldHideWebUI and WEB_UI_ALLOW
1 parent 6425254 commit 6763eaa

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ COS_DOWNLOAD_URL=
107107

108108
# The value should be a comma-separated list of IP addresses, e.g., "127.0.0.1,10.0.0.1".
109109
WEB_UI_WHITELIST=
110+
WEB_UI_ALLOW=

src/core/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export const config = {
138138
.split(',')
139139
.map((ip) => ip.trim())
140140
.filter(Boolean),
141+
// options value is (true | false), when it's true, web UI routes are enabled (still restricted by IP whitelist if configured)
142+
webUIAllow: toBool(process.env.WEB_UI_ALLOW),
141143
},
142144
// Config for smtp email, register module need validate user email project source https://github.com/nodemailer/nodemailer
143145
smtpConfig: {

src/core/utils/common.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import { config } from '../config';
1313

1414
const streamPipeline = util.promisify(pipeline);
1515

16-
/** 프로덕션이거나, ALLOW_REGISTRATION !== true 이면 UI 숨김 */
16+
/** WEB_UI_ALLOW !== true 이면 UI 숨김 */
1717
export function shouldHideWebUI(): boolean {
18-
const env = config.common.env || process.env.NODE_ENV;
19-
const isProdEnv = env === 'production';
20-
const allowRegistration = Boolean(config.common.allowRegistration);
18+
const allowWebUiInProd = config.common.webUIAllow;
2119

22-
return isProdEnv || !allowRegistration;
20+
return !allowWebUiInProd;
2321
}
2422

2523
function cleanVersion(versionNo?: string) {

0 commit comments

Comments
 (0)