From bcba0f598a86a18c447d1cc33cf4356334a1909b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Nov 2026 18:53:44 +0800 Subject: [PATCH] fix(admin): stop the browser autofilling credentials into the settings search box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A settings screen renders twenty-odd AppSecret and private-key fields as type="password". Chrome reads any page carrying a password input as a login form and fills the saved username and password into the first text box it finds — the settings search field at the top of the panel. Suppressing autocomplete on that one input could not fix it, because the trigger is the password inputs elsewhere on the page. Secret fields now render as text with CSS masking (-webkit-text-security: disc), so they still look like ciphertext but no longer register as password inputs; the mask lifts on focus so a freshly typed value can be checked. That covers the 21 schema-driven fields through JioField plus the four captcha provider forms and the WeChat template page. The search box keeps a second layer of defence: a descriptive name and autocomplete/autocorrect/spellcheck disabled, with the LastPass and 1Password ignore markers set. Verification: vite build succeeds and the emitted bundles no longer contain a single type="password"; 980 admin/widget tests pass. Note: assets/admin/build/ is gitignored, so the production build must be run on deploy. -webkit-text-security is WebKit/Blink only — Firefox falls back to plain text. --- .../src/components/captcha/AliyunConfig.vue | 3 ++- .../components/captcha/CloudflareConfig.vue | 2 +- .../src/components/captcha/GeetestConfig.vue | 2 +- .../src/components/captcha/TencentConfig.vue | 4 ++-- assets/admin/src/components/form/JioField.vue | 24 ++++++++++++++++++- .../src/components/form/JioFormRenderer.vue | 14 +++++++++++ .../src/pages/users/UsersWechatTemplate.vue | 2 +- assets/admin/src/style.css | 16 +++++++++++++ 8 files changed, 60 insertions(+), 7 deletions(-) diff --git a/assets/admin/src/components/captcha/AliyunConfig.vue b/assets/admin/src/components/captcha/AliyunConfig.vue index 4c1f5d1c..b12a2d59 100644 --- a/assets/admin/src/components/captcha/AliyunConfig.vue +++ b/assets/admin/src/components/captcha/AliyunConfig.vue @@ -38,8 +38,9 @@ - + 清除 diff --git a/assets/admin/src/components/captcha/GeetestConfig.vue b/assets/admin/src/components/captcha/GeetestConfig.vue index e367eb15..5472df46 100644 --- a/assets/admin/src/components/captcha/GeetestConfig.vue +++ b/assets/admin/src/components/captcha/GeetestConfig.vue @@ -5,7 +5,7 @@ - + 清除 ✓ 已完整配置 diff --git a/assets/admin/src/components/captcha/TencentConfig.vue b/assets/admin/src/components/captcha/TencentConfig.vue index 9ccf6041..d941d90a 100644 --- a/assets/admin/src/components/captcha/TencentConfig.vue +++ b/assets/admin/src/components/captcha/TencentConfig.vue @@ -9,7 +9,7 @@ - + 清除 @@ -18,7 +18,7 @@ - + 清除 diff --git a/assets/admin/src/components/form/JioField.vue b/assets/admin/src/components/form/JioField.vue index 29da61e3..37014958 100644 --- a/assets/admin/src/components/form/JioField.vue +++ b/assets/admin/src/components/form/JioField.vue @@ -29,8 +29,11 @@ @@ -572,6 +575,14 @@ const fieldClasses = computed(() => ({ [`jio-field--${props.schema.type}`]: !!props.schema.type, })) +/** + * 凭证字段不向浏览器暴露成密码输入。 + * + * 设置页往往一次渲染二十多个 AppSecret/私钥,只要页面上出现 type="password", + * Chrome 就会把整页判定为登录表单,并把保存的账号密码灌进第一个文本框 + * (顶部的设置项搜索框)。这里把凭证字段降级为 text 并用 CSS 的 + * -webkit-text-security 做遮蔽:视觉上仍是密文,但浏览器不再识别成密码框。 + */ const secretMarkedForClear = computed(() => props.schema.secret && props.modelValue === '__JIO_CLEAR_SECRET__') const secretDisplayValue = computed(() => secretMarkedForClear.value ? '' : props.modelValue) /** 已配置密钥(服务端回传 '***'):textarea 不回显掩码,留空即保持原值。 */ @@ -579,6 +590,17 @@ const secretConfigured = computed(() => props.schema.secret && props.modelValue const secretClearVisible = computed(() => secretConfigured.value || secretMarkedForClear.value) const secretTextareaValue = computed(() => secretConfigured.value ? '' : secretDisplayValue.value) +/** 凭证字段的输入属性:彻底关掉自动填充与密码管理器的识别。 */ +const secretInputProps = { + autocomplete: 'off', + autocorrect: 'off', + autocapitalize: 'off', + spellcheck: 'false', + 'data-lpignore': 'true', + 'data-1p-ignore': 'true', + 'data-form-type': 'other', +} + function toggleSecretClear() { emit('update:modelValue', secretMarkedForClear.value ? '***' : '__JIO_CLEAR_SECRET__') } diff --git a/assets/admin/src/components/form/JioFormRenderer.vue b/assets/admin/src/components/form/JioFormRenderer.vue index 92bf0de8..361694c7 100644 --- a/assets/admin/src/components/form/JioFormRenderer.vue +++ b/assets/admin/src/components/form/JioFormRenderer.vue @@ -15,6 +15,8 @@ placeholder="搜索设置项..." size="small" clearable + name="jio-settings-search" + :input-props="searchInputProps" >