security: Token 改为 HttpOnly Cookie 下发,消除 XSS 窃取面

登录时网关签发 HttpOnly+Secure+SameSite=Lax 的 q4_token Cookie,前端不再经手 Token;网关代理时支持从 Cookie 验签并向下游注入 Authorization(dnfs 零改动),新增 /logout 清除 Cookie,static 代理路由兼容 Cookie 转 Bearer。
This commit is contained in:
qing committed 2026-07-28 09:07:12 +08:00
1 parent 65cfaf97a1
commit e89578fa82
4 files changed
+102 -28

No files matched your search

+1 -2
View File
@@ -76,8 +76,7 @@ form.addEventListener('submit', async function(e) {
try { result = JSON.parse(responseText); } catch { throw new Error('服务器响应格式异常'); }
if (!res.ok) throw new Error(result.message || '登录失败');
if (result.success) {
localStorage.setItem('q4_token', result.data.token);
sessionStorage.setItem('q4_token', result.data.token);
// Token 已由网关通过 HttpOnly Cookie 下发,JS 不再经手
alert('登录成功');
location.href = '/dnfs.html';
} else {