feat: add JWT secret safety checks and warning page for insecure configurations

This commit is contained in:
shuaiplus
2026-03-01 18:31:44 +08:00
committed by Shuai
parent bbf4094943
commit f5a2523f91
6 changed files with 214 additions and 3 deletions
+46
View File
@@ -171,6 +171,29 @@ const messages: Record<Locale, Record<string, string>> = {
txt_linux_desktop: "Linux Desktop",
txt_loading: "Loading...",
txt_loading_nodewarden: "Loading NodeWarden...",
txt_jwt_warning_title: "Server Security Warning",
txt_jwt_warning_subtitle: "JWT secret is not configured safely.",
txt_jwt_title_missing: "JWT_SECRET is missing",
txt_jwt_title_too_short: "JWT_SECRET is too short",
txt_jwt_title_default: "JWT_SECRET is using the default value",
txt_jwt_reason_missing: "JWT secret is missing.",
txt_jwt_reason_default: "JWT secret is still the default/sample value.",
txt_jwt_reason_too_short: "JWT secret is too short. Minimum length is {min}.",
txt_jwt_how_to_fix_add: "How to add JWT_SECRET",
txt_jwt_how_to_fix_replace: "How to replace JWT_SECRET",
txt_jwt_add_step_1: "Use the 32-character generator below and copy a new key.",
txt_jwt_add_step_2: "Cloudflare Dashboard -> Workers & Pages -> Your Service -> Settings -> Variables and Secrets, add JWT_SECRET.",
txt_jwt_add_step_3: "Save and wait for redeploy, then refresh this page.",
txt_jwt_replace_step_1: "Use the 32-character generator below and create a stronger key (minimum {min} characters).",
txt_jwt_replace_step_2: "Cloudflare Dashboard -> Workers & Pages -> Your Service -> Settings -> Variables and Secrets, replace JWT_SECRET.",
txt_jwt_replace_step_3: "Save and wait for redeploy, then refresh this page.",
txt_how_to_fix: "How to fix",
txt_jwt_fix_step_1: "Open your deployment environment variables.",
txt_jwt_fix_step_2: "If your current key is not random enough, use the 32-character generator below.",
txt_jwt_fix_step_3: "Cloudflare Dashboard -> Workers & Pages -> Your Service -> Settings -> Variables and Secrets, update JWT_SECRET.",
txt_jwt_fix_step_4: "Save and wait for redeploy, then refresh this page to verify.",
txt_random_secret_generator: "Random Secret Generator",
txt_copied: "Copied",
txt_log_in: "Log In",
txt_log_out: "Log Out",
txt_login: "Login",
@@ -672,6 +695,29 @@ const zhCNOverrides: Record<string, string> = {
txt_verify: '验证',
txt_web: '网页',
txt_windows_desktop: 'Windows 桌面端',
txt_jwt_warning_title: 'JWT_SECRET 配置警告',
txt_jwt_warning_subtitle: 'JWT 密钥当前不安全,请先修复后再继续。',
txt_jwt_title_missing: '未检测到 JWT_SECRET',
txt_jwt_title_too_short: 'JWT_SECRET 长度过短',
txt_jwt_title_default: 'JWT_SECRET使用默认值',
txt_jwt_reason_missing: '未检测到 JWT_SECRET。',
txt_jwt_reason_default: 'JWT_SECRET 仍在使用默认示例值。',
txt_jwt_reason_too_short: 'JWT_SECRET 长度过短,至少需要 {min} 位。',
txt_jwt_how_to_fix_add: '处理步骤(添加 JWT_SECRET',
txt_jwt_how_to_fix_replace: '处理步骤(更换 JWT_SECRET',
txt_jwt_add_step_1: '使用下方 32 位随机生成器,复制一个新密钥。',
txt_jwt_add_step_2: '到 Cloudflare 控制台 -> Workers 和 Pages -> 你的服务 -> 设置 -> 变量和机密,新增 JWT_SECRET。',
txt_jwt_add_step_3: '保存并等待重新部署完成,然后刷新本页确认。',
txt_jwt_replace_step_1: '使用下方 32 位随机生成器,生成更强的密钥(至少 {min} 位)。',
txt_jwt_replace_step_2: '到 Cloudflare 控制台 -> Workers 和 Pages -> 你的服务 -> 设置 -> 变量和机密,替换 JWT_SECRET。',
txt_jwt_replace_step_3: '保存并等待重新部署完成,然后刷新本页确认。',
txt_how_to_fix: '处理步骤(添加 / 更换)',
txt_jwt_fix_step_1: '你可以继续下一步,不影响使用。',
txt_jwt_fix_step_2: '如果当前密钥不是强随机值,建议使用下方 32 位生成器。',
txt_jwt_fix_step_3: '到 Cloudflare 控制台 -> Workers 和 Pages -> 你的服务 -> 设置 -> 变量和机密,更新 JWT_SECRET。',
txt_jwt_fix_step_4: '保存并等待重新部署完成,然后刷新本页确认。',
txt_random_secret_generator: '随机密钥生成器',
txt_copied: '已复制',
};
messages['zh-CN'] = { ...messages.en, ...zhCNOverrides };