From d028d390ebe773988921d22c444f7f5ccc26fd75 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Wed, 13 May 2026 11:17:29 +0200 Subject: [PATCH] Revert "feat(auth): block panel with default admin/admin credentials and guide credential change" This reverts commit 56ce6073ce09f08147f989858e0e88b3a4359546. --- frontend/src/pages/login/LoginPage.vue | 4 +- frontend/src/pages/settings/SecurityTab.vue | 42 ++------ frontend/src/pages/settings/SettingsPage.vue | 104 +++++-------------- web/controller/base.go | 35 +------ web/controller/dist.go | 9 +- web/controller/index.go | 16 +-- web/controller/setting.go | 47 +-------- web/service/node.go | 1 - web/service/user.go | 15 --- web/service/xray_metrics.go | 8 +- 10 files changed, 47 insertions(+), 234 deletions(-) diff --git a/frontend/src/pages/login/LoginPage.vue b/frontend/src/pages/login/LoginPage.vue index bbccbcef..fab7ba9d 100644 --- a/frontend/src/pages/login/LoginPage.vue +++ b/frontend/src/pages/login/LoginPage.vue @@ -52,9 +52,7 @@ async function login() { submitting.value = true; try { const msg = await HttpUtil.post('/login', user); - if (msg.success) { - window.location.href = basePath + (msg.obj?.mustChangeCredentials ? 'panel/settings' : 'panel/'); - } + if (msg.success) window.location.href = basePath + 'panel/'; } finally { submitting.value = false; } diff --git a/frontend/src/pages/settings/SecurityTab.vue b/frontend/src/pages/settings/SecurityTab.vue index 3edb1f3b..d841c787 100644 --- a/frontend/src/pages/settings/SecurityTab.vue +++ b/frontend/src/pages/settings/SecurityTab.vue @@ -21,10 +21,9 @@ const tfa = reactive({ description: '', token: '', type: 'set', - // resolveConfirm is called by the modal's @confirm with the success bool - // and, for redacted-token confirm flows, the code entered by the user. + // resolveConfirm is called by the modal's @confirm with the success bool; // it then routes the value back to whichever flow opened the modal. - resolveConfirm: (_success, _code) => { }, + resolveConfirm: (_success) => { }, }); function openTfa({ title, description = '', token = '', type, onConfirm }) { @@ -36,8 +35,8 @@ function openTfa({ title, description = '', token = '', type, onConfirm }) { tfa.open = true; } -function onTfaConfirm(success, code = '') { - tfa.resolveConfirm(success, code); +function onTfaConfirm(success) { + tfa.resolveConfirm(success); } const user = reactive({ @@ -53,23 +52,16 @@ async function sendUpdateUser() { try { const msg = await HttpUtil.post('/panel/setting/updateUser', user); if (msg?.success) { - await logoutAndReturn(); + // Force re-login at the standard logout path; basePath is handled + // by the Go router so a relative redirect is correct here. + const basePath = window.X_UI_BASE_PATH || ''; + window.location.replace(`${basePath}logout`); } } finally { updating.value = false; } } -async function logoutAndReturn() { - await HttpUtil.post('/logout'); - window.location.replace(window.X_UI_BASE_PATH || '/'); -} - -async function verifyTwoFactor(code) { - const msg = await HttpUtil.post('/panel/setting/verifyTwoFactor', { code }); - return !!(msg?.success && msg.obj === true); -} - function updateUser() { if (props.allSetting.twoFactorEnable) { openTfa({ @@ -77,11 +69,7 @@ function updateUser() { description: t('pages.settings.security.twoFactorModalChangeCredentialsStep'), token: props.allSetting.twoFactorToken, type: 'confirm', - onConfirm: async (ok, code) => { - if (!ok) return; - const verified = props.allSetting.twoFactorToken ? ok : await verifyTwoFactor(code); - if (verified) sendUpdateUser(); - }, + onConfirm: (ok) => { if (ok) sendUpdateUser(); }, }); } else { sendUpdateUser(); @@ -100,10 +88,7 @@ async function loadApiToken() { apiTokenLoading.value = true; try { const msg = await HttpUtil.get('/panel/setting/getApiToken'); - if (msg?.success) { - apiToken.value = msg.obj || ''; - props.allSetting.hasApiToken = !!apiToken.value; - } + if (msg?.success) apiToken.value = msg.obj || ''; } finally { apiTokenLoading.value = false; } @@ -139,7 +124,6 @@ function regenerateApiToken() { const msg = await HttpUtil.post('/panel/setting/regenerateApiToken'); if (msg?.success) { apiToken.value = msg.obj || ''; - props.allSetting.hasApiToken = !!apiToken.value; message.success(t('success')); } } finally { @@ -163,7 +147,6 @@ function toggleTwoFactor() { if (ok) { message.success(t('pages.settings.security.twoFactorModalSetSuccess')); props.allSetting.twoFactorToken = newToken; - props.allSetting.hasTwoFactorToken = true; } props.allSetting.twoFactorEnable = ok; }, @@ -174,14 +157,11 @@ function toggleTwoFactor() { description: t('pages.settings.security.twoFactorModalRemoveStep'), token: props.allSetting.twoFactorToken, type: 'confirm', - onConfirm: async (ok, code) => { + onConfirm: (ok) => { if (!ok) return; - const verified = props.allSetting.twoFactorToken ? ok : await verifyTwoFactor(code); - if (!verified) return; message.success(t('pages.settings.security.twoFactorModalDeleteSuccess')); props.allSetting.twoFactorEnable = false; props.allSetting.twoFactorToken = ''; - props.allSetting.hasTwoFactorToken = false; }, }); } diff --git a/frontend/src/pages/settings/SettingsPage.vue b/frontend/src/pages/settings/SettingsPage.vue index 2166a259..5f2ddf39 100644 --- a/frontend/src/pages/settings/SettingsPage.vue +++ b/frontend/src/pages/settings/SettingsPage.vue @@ -26,9 +26,6 @@ const { t } = useI18n(); const { fetched, spinning, saveDisabled, allSetting, saveAll } = useAllSetting(); const { isMobile } = useMediaQuery(); -const mustChangeCredentials = window.X_UI_MUST_CHANGE_CREDENTIALS === true -const activeTab = ref(mustChangeCredentials ? '2' : '1') - const basePath = window.X_UI_BASE_PATH || ''; const requestUri = window.location.pathname; @@ -120,68 +117,39 @@ function restartPanel() { }); } -const securityChecklist = computed(() => { - const segs = window.location.pathname.split('/').length < 4; - const out = [] - if (mustChangeCredentials) { - out.push({ - label: 'Default credentials', - ok: false, - action: 'Change the default admin/admin credentials in Authentication settings.', - }) +// Conf alerts mirror the legacy banner — pure derivation off allSetting. +const confAlerts = computed(() => { + const out = []; + if (window.location.protocol !== 'https:') { + out.push('Panel is served over plain HTTP — set up TLS for production.'); + } + if (allSetting.webPort === 2053) { + out.push('Default port 2053 is well-known — change it to a random port.'); + } + const segs = window.location.pathname.split('/').length < 4; + if (segs && allSetting.webBasePath === '/') { + out.push('Default base path "/" is well-known — change it to a random path.'); } - out.push( - { - label: 'TLS', - ok: window.location.protocol === 'https:', - action: 'Set certificate and key paths, then restart.', - }, - { - label: 'Base path', - ok: !(segs && allSetting.webBasePath === '/'), - action: 'Change the panel URL path from "/".', - }, - { - label: 'Panel port', - ok: allSetting.webPort !== 2053, - action: 'Use a non-default listening port.', - }, - { - label: 'Two-factor authentication', - ok: allSetting.twoFactorEnable && allSetting.hasTwoFactorToken, - action: 'Enable 2FA in Security.', - }, - { - label: 'API token', - ok: allSetting.hasApiToken, - action: 'Generate or rotate the API token in Security.', - }, - ) if (allSetting.subEnable) { let subPath = allSetting.subPath; if (allSetting.subURI) { try { subPath = new URL(allSetting.subURI).pathname; } catch (_e) { } } - out.push({ - label: 'Subscription path', - ok: subPath !== '/sub/', - action: 'Change the default subscription path.', - }); + if (subPath === '/sub/') { + out.push('Default subscription path "/sub/" is well-known — change it.'); + } } if (allSetting.subJsonEnable) { let p = allSetting.subJsonPath; if (allSetting.subJsonURI) { try { p = new URL(allSetting.subJsonURI).pathname; } catch (_e) { } } - out.push({ - label: 'JSON subscription path', - ok: p !== '/json/', - action: 'Change the default JSON subscription path.', - }); + if (p === '/json/') { + out.push('Default JSON subscription path "/json/" is well-known — change it.'); + } } return out; }); -const hasSecurityGaps = computed(() => securityChecklist.value.some((item) => !item.ok)); const alertVisible = ref(true); @@ -197,31 +165,14 @@ const alertVisible = ref(true);