DeepSeek Harness Hub
← 返回列表

登录闸门Wayne036/dsh-plugin-login-gate

DeepSeek 客户端兼容 / 相关生态spec-screened在 GitHub 查看 ↗
未验证

为 Web UI 加密码登录与 HTTPS 反代

尚未跑自动兼容性验证,可查看页面内的依赖与入口分析。 · 最近上游提交 2026/9/5 · 已提供中文文档
综合分
29.6
GitHub 分
29.6
用户评分
★ Stars
1
周下载量
兼容 / 相关生态插件(非 dsh 原生,请按其对应运行时安装)
git clone https://github.com/Wayne036/dsh-plugin-login-gate.git
数据截至 2026/9/16(元数据每日更新 · 实装验证按队列轮转,单条结论的验证时间见上方)
依赖的 DSH / Cordis 模块
@deepseek-ai/cordis
用户评分
还没有人投票,来当第一个
订阅周报,不错过优质插件更新
每周一封 · 高评分插件 + 新用户活动

README

dsh-plugin-login-gate

为 DeepSeek Harness (dsh) Web UI 增加密码登录闸门 + HTTPS 反向代理的 Cordis 插件。

适用场景:dsh Web UI 默认无登录页(仅回环地址访问)。当你需要把 dsh 暴露给局域网 /
内网其他设备时,本插件在 dsh 前置一道登录,未授权设备无法使用 dsh。

特性

- 密码登录:单密码即可(单用户场景),密码文件明文存储、修改即时生效
- HTTPS 自签:自签证书加密传输,首次访问点一次「继续前往」即可(与常见 NAS 体验一致)
- http → https 自动跳转:直接输 IP:端口 也能打开
- 会话安全:httpOnly Cookie、浏览器会话级(关浏览器即失效)
- SSE / WebSocket 转发:dsh 的流式输出与实时能力不受影响
- 同端口双协议:一个端口同时处理 HTTP 跳转与 HTTPS
- 零 npm 运行时依赖(仅 peer 依赖 @deepseek-ai/cordis)

安装

1. 获取插件

方式 A:Git 克隆
git clone https://github.com//dsh-plugin-login-gate.git

方式 B:手动下载本仓库 zip 并解压

将插件目录放入 dsh 可访问的位置(如 dsh 安装目录、或任意本地目录)。

2. 注册到 profile

编辑 dsh profile 的 cordis.patch.yml(例如 ~/.dsh/profiles/web/cordis.patch.yml),
或全局用户层 ~/.dsh/cordis.patch.yml,追加:

- insert:
- id: login-gate
name: 'dsh-plugin-login-gate'
config:
port: 3081
passwordFile: 'C:/dsh/login-gate/password.txt'
certFile: 'C:/dsh/login-gate/cert.pem'
keyFile: 'C:/dsh/login-gate/key.pem'
assetsDir: 'C:/dsh/login-gate/assets'

若 dsh-plugin-login-gate 未安装到 dsh 能解析的 node_modules,可将 name
指向插件目录的绝对路径(如 name: 'C:/dsh/dsh-plugin-login-gate')。

3. 生成证书(一次性)

用本机 openssl 生成自签证书(有效期 10 年,把  换成实际值):

openssl req -x509 -newkey rsa:2048 \
-keyout key.pem -out cert.pem -days 3650 -nodes \
-subj "/CN=DeepSeek-Harness-Login" \
-addext "subjectAltName=IP:127.0.0.1,DNS:localhost,IP:"

4. 设置密码

创建密码文件,内容为你的登录密码(明文,改完即时生效):

echo '你的密码' > C:/dsh/login-gate/password.txt

5. (可选)自定义素材

插件包内已内置默认素材——assets/logo.svg(dsh 官方鲸鱼图标)和
assets/bg.jpg(晨雾山景背景图),开箱即有完整美观度。

如需替换:在 cordis.patch.yml 的插件行 config 中设置 assetsDir
指向你的自定义目录(直接放 logo.svg / bg.jpg,无需 assets/
子目录,文件名匹配即可)。示例:

config:
assetsDir: 'C:/dsh/login-gate-custom'   # 内含 logo.svg、bg.jpg 即可

替换优先级:自定义目录 > 包内默认。

6. 重启 dsh

重启 dsh Web UI 后,插件随 dsh 启动。浏览器访问:

http://:    → 自动跳转 https
https://:   → 登录页

首次访问自签证书浏览器会提示「连接不是私密连接」,点「高级 → 继续前往」即可,
之后该地址不再提示(每台设备首次各点一次)。

安装常见问题

node-pty 构建脚本被 pnpm 默认拦截(build scripts are blocked)

安装依赖 node-pty(dsh 终端能力)的插件时,pnpm v10+ 默认不执行 build scripts,
安装会报「构建脚本被 pnpm 默认拦截(node-pty)」。在 dsh profile 目录下
(如 ~/.dsh/profiles/web/)的 pnpm-workspace.yaml 里放行即可:

allowBuilds:
node-pty: true

之后重新运行安装(或点击插件商店的「Allow build scripts and retry」)即可通过。
其它原生依赖被拦时同理,把包名加进 allowBuilds。

配置项

| 键 | 必填 | 默认 | 说明 |
|---|---|---|---|
| host | 否 | 0.0.0.0 | 监听地址 |
| port | 否 | 3081 | 监听端口(登录闸门入口) |
| targetHost | 否 | 127.0.0.1 | 转发目标(dsh 所在地址) |
| targetPort | 否 | 3080 | 转发目标端口(dsh Web UI 端口) |
| passwordFile | 是 | - | 密码文件路径(明文) |
| certFile | 是 | - | TLS 证书 PEM 路径 |
| keyFile | 是 | - | TLS 私钥 PEM 路径 |
| assetsDir | 否 | 包内 assets/ | 登录页素材目录(bg.jpg / logo.svg) |
| maxSessions | 否 | 64 | 最大并发登录会话数(多端场景) |
| lanPatch | 否 | false | 局域网跨设备访问修复开关(仅浏览器侧)。开启后会在 dsh 的 dsh-client-connection 里,把客户端派生的 connection.isLoopback 状态对私有网段也判为 true,让设置页在局域网下可用;只改这一处、不动 isLoopbackHostname() 函数,因此不影响服务端 /api 信任围栏。dsh 更新/重装后需重打补丁(见下文)。默认关闭 = 不改动 dsh 宿主文件。 |

配置缺失或文件不存在时,插件仅记录警告并跳过启动,不影响 dsh 本体。

本插件与 dsh 自身 webserver(默认 127.0.0.1:3080)是两回事:插件作为
对外入口(如 3081),dsh 本体保持仅本机可访问。建议 dsh 的 webserver.host
保持 127.0.0.1,不要暴露到局域网,由本插件统一对外。

安全说明

- 密码明文存储于你指定的本地文件,请确保该文件仅你可读写(单用户个人工具设计)。
- 使用自签证书时,密码在传输中加密;但自签 CA 不被浏览器信任,请勿将该入口暴露到
公网。仅限受信任的局域网/内网(VPN)环境使用。
- 会话为内存存储:dsh 重启后所有设备需重新登录。

局域网跨设备访问(LAN)修复说明

把 dsh 暴露给局域网 / 内网其他设备时,会出现两类与「跨设备访问」直接相关的 BUG。
本插件对两类都做了处理:服务端在代理层修,浏览器侧在启动时自动打补丁。

BUG 1:模型配置页报 HTTP 403(transport failure for /api/settings.describe)

- 根因:dsh 对 settings.describe 等特权接口按请求头 Host / Origin
做信任判定,只接受回环(loopback)或 --trusted-host 指定的 authority。
反向代理把请求转发到 127.0.0.1:3080 时,若 Host / Origin 仍带着局域网
地址(如 192.168.x.x:3081),就会被信任围栏拒绝,返回 403。
注意 --trusted-host 只覆盖「trusted-host 类」接口,无法覆盖「loopback 类」
接口,所以光加 trusted-host 不够。
- 修复(本插件已在代理层处理):见 lib/index.js 的 rewriteLoopbackAuthority(),
在把请求(含 WebSocket 升级)转发给 dsh 之前,把 Host / Origin 重写为目标
回环地址(127.0.0.1:3080)。你无需手动处理。

BUG 2:设置 / 模型配置页报 settings are unavailable in this browser

- 根因:这是纯前端判定,与上面的 403 是两回事。浏览器端
dsh-client-connection 的 isLoopbackHostname() 只认 localhost / 127.x;
connection.isLoopback 由页面 location.hostname 算出。经局域网 IP 访问时
isLoopback=false → 设置镜像 persistence="memory" → 永不发起 settings.describe
→ 抛该错。
- 修复(需开启 lanPatch,本插件在启动时自动打浏览器侧补丁):
该浏览器侧补丁默认不启用(lanPatch: false)。只有局域网设备需要打开设置页时,
才在插件行 config 设 lanPatch: true;未开启时 dsh 内部文件原样不动(更安全)。

补丁只改一处,且刻意不动 isLoopbackHostname() 函数本体:

dsh-client-connection/lib/client.js 里派生的 connection.isLoopback 状态,
原本是 pageLocation === void 0 || isLoopbackHostname(pageLocation.hostname),
补丁在其后追加一段私有网段判定(10/8、172.16/12、192.168/16、169.254/16):
局域网 IP 访问时 isLoopback 也判为 true → 设置镜像改用 host 持久化、正常加载。

为什么不动 isLoopbackHostname() 函数?该函数同时被服务端 /api 信任围栏
(api-request-trust.ts)使用;若在此处放宽,等于把整个局域网当成回环可信,
特权接口在 LAN 下无需 --trusted-host 即达,扩大信任边界。只改客户端派生状态,
信任围栏仍只认真正的回环 / trusted-host,既修好设置页又不引入该副作用。
- 补丁是侵入式的,改在 dsh 自家 node_modules 内部文件里:

⚠️ dsh 一旦更新 / 重装,这些补丁会失效,设置页会再次报 BUG 2。
因此本插件在 apply() 启动时(最佳努力、幂等)自动重打;
若自动探测未命中,或你想手动确认,在 dsh 更新后执行一次即可:

自动探测 dsh 安装目录(从 cwd / 插件位置向上回溯)
node node_modules/dsh-plugin-login-gate/patch-dsh-lan.js

或显式指定 dsh 根目录(最稳妥)
node node_modules/dsh-plugin-login-gate/patch-dsh-lan.js C:/AI/deepseek-dsh
等价写法:
DSH_ROOT=C:/AI/deepseek-dsh node node_modules/dsh-plugin-login-gate/patch-dsh-lan.js

脚本特性:幂等(已打过则跳过)、不写死任何 IP / 密码、匹配不到模式就不动文件、
打前自动留 .lanpatch.bak 备份。

BUG 3:跨设备会话列表 / 实时事件流为空(WebSocket 握手失败)

- 根因:作为反向代理转发 WebSocket 升级时,Upgrade / Connection 属 hop-by-hop
The head is stripped and not restored, while RFC 6455 requires the 101 response to carry these two headers → browser-side handshake validation
fails (the console reports WebSocket is closed before the connection is established),
and the dsh event stream (/api/events.mux / /api/events.host, which carries real-time data such as the session list) cannot be established across devices
→ workspace conversation tasks / session history are only displayed on the local machine.
- Fix: Restore Upgrade: websocket and Connection: Upgrade before forwarding the 101 response.
- Related: The old gateway set a 30s idle timeout for forwarded requests, which would mistakenly kill idle long-lived connections
(such as the /plugins/events hot-reload SSE, where the client reports ERR_INCOMPLETE_CHUNKED_ENCODING).
This has now been removed; ordinary API requests are covered by the client timeout as a fallback.

Verification (recommended to run once after each dsh update)

1) After logging in from a LAN device, the settings page should open, with no more 403 / unavailable
2) Use node to connect directly and verify that settings.describe returns 200:
node -e "const https=require('https');https.get('https://127.0.0.1:3080/api/settings.describe',{rejectUnauthorized:false},r=>{console.log('status',r.statusCode);r.destroy();}).on('error',e=>console.log('err',e.message))"
3) Hard-refresh the browser (Ctrl+F5) to load the patched new client module

For the complete troubleshooting / quick-fix manual, see dsh-局域网跨设备访问修复手册.md at the same level as the repository
(a locally retained document, containing no local IPs / passwords).

Known Limitations

- Single password, no multi-user system (positioned as a personal tool).
- No login failure lockout (if protection against brute-force attacks is needed, you can add a firewall / rate limiting in front of the reverse proxy yourself).
- The self-signed certificate is valid for 10 years; upon expiration, it must be regenerated and the configuration updated.

Changelog

- v0.2.2 — The LAN browser-side patch has been narrowed down to a single precise patch: only the client's connection.isLoopback state is judged as true for private network segments (so that the settings page remains persistently available under LAN), and the isLoopbackHostname() function is no longer modified, avoiding affecting the server-side /api trust fence (previously, relaxing that function would treat the entire LAN as loopback-trusted). The old redundant patch for dsh-client-ui-settings has been removed (the new version of that package has been refactored into a pure UI shell, and the target string no longer exists). Residual function-level relaxation from the old version will be automatically rolled back and migrated.
- v0.2.1 — lanPatch now defaults to false (explicitly enabled). If not configured = dsh host files are not modified; only after enabling will dsh internal packages be patched in place to make the settings page available under LAN. After a dsh update/reinstall, the patch needs to be reapplied (see "LAN Cross-Device Access Fix Instructions").
- v0.2.0 — Fixed two types of cross-device access issues: restore the Upgrade / Connection headers in the WebSocket 101 response (BUG 3, event stream / session list visible across devices); removed the 30s idle timeout for forwarded requests (to avoid mistakenly killing long-lived connections such as /plugins/events). Added pnpm allowBuilds instructions to allow node-pty installation.
- v0.1.0 — Initial version: password login gate + HTTPS self-signed reverse proxy, http→https redirect, SSE / WebSocket forwarding, browser-side LAN patch (fixes settings page 403 / settings are unavailable).

License

MIT

上游仓库有新提交时邮件通知你(每天最多一封,无更新不打扰),随时一键退订。

💬 加入 DPharness 群聊

插件用法、部署报错、新插件第一时间同步——群里问,比一个人翻文档快。

点击加入 QQ 群
DPharness 群聊二维码,手机 QQ 扫码进群
扫码进群