AlistGo / AlistGo/alist

能不能将 jwt 存储于 Cookie 而不是 LocalStorage?

Abierto
#8,140 1 comentario 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Go
Estrellas
50.2k
Forks
7.9k
Merge medio
7 d 21 h
PR fusionados (30 d)
6

Descripción

### Please make sure of the following things

- [x] I have read the [documentation](https://alist.nn.ci).
- [x] I'm sure there are no duplicate issues or discussions.
- [x] I'm sure this feature is not implemented.
- [x] I'm sure it's a reasonable and popular requirement.

### Description of the feature / 需求描述

**以下为 Deepseek 生成**

```plaintext
Alist 当前将 JWT 存储在 LocalStorage 中,同时允许用户添加外部 JS 文件作为自定义预览器(如通过 custom/js 路径)。这两者的组合会显著增加 XSS 攻击导致 JWT 泄露 的风险:

攻击者可上传伪装成“预览脚本”的恶意 JS 文件(例如 malicious-preview.js)。
当用户访问包含此文件的页面时,恶意脚本会自动执行,直接读取 LocalStorage 中的 JWT
攻击者窃取 JWT 后,可完全控制用户会话(增删文件、获取云存储凭据等)。

问题根源:
LocalStorage 开放性:任何页面内的 JS(包括第三方脚本)均可无限制访问 LocalStorage。
外部 JS 不可控性:Alist 允许用户自定义 JS 预览脚本,但无法保证这些脚本的安全性。
```

我对这方面了解不多,DS提到了“隔离外部 JS 执行环境,使用 sandbox 属性加载预览脚本”的方法,我不确定 AList 是否已经使用了足够的措施来防止 XSS 攻击,或者自己用根本不需要考虑 XSS?

### Suggested solution / 实现思路

我想应该可以让 Cookie 这套和原来 Authorization 那套共存?获取 jwt 时服务端发送带 Set-Cookie 的头的同时在响应体 json 里也有一份,验证身份可以 Cookie 和 Authorization 二选一

### Additional context / 附件

_No response_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.