bamboostrip/dsh-access-gate ↗★ 1
dsh-access-gate
为远程API访问提供密码认证网关。 适合有公网或局域网远程访问需求、需要保护接口安全的用户。
安裝
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:bamboostrip/dsh-access-gate說明文件
閱讀完整 README ↗① 推荐:DSH 设置界面 → 插件配置 → 访问认证 卡片
使用
- 默认无密码:远程(公网域名 / 局域网 IP)直接访问。
- 设置密码后:本机
http://127.0.0.1:3080免密;远程首次访问 302 到登录页,登录后 7 天内免登录(有效期可配)。 - DSH 0.1.2-rc.1 起启动带
?token=(每进程随机浏览器会话):远程用户无需知道它 —— 密码登录成功后服务端自动把当前 token 注入重定向(浏览器随后自动完成 DSH 交换;进程重启后书签里的旧 token 下次登录时自动刷新)。 - nginx 与 DSH 同机时(remote 恒为 127.0.0.1 但 Host 是域名)同样需要密码 —— 公网流量无法绕过认证。
- 登录态在内存:DSH 进程重启后需重新登录。
公网 nginx 参考配置
server {
listen 443 ssl;
server_name codsh.famlife.top;
# ssl_certificate ...; ssl_certificate_key ...;
location / {
proxy_pass http://10.144.144.7:3080; # 家里 DSH
proxy_http_version 1.1; # ★ 必须(默认 1.0 会断 WS)
proxy_set_header Host $host; # 域名原样转发
proxy_set_header Upgrade $http_upgrade; # ★ WS 必需
proxy_set_header Connection "upgrade"; # ★ WS 必需
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_buffering off;
}
}
公网 403 排查清单见 NOTES.md。
可选配置(profiles/web/cordis.patch.yml 覆盖 auth-gate 行)
- id: auth-gate
config:
# password: 'xxx' # 可选:行配置密码(最高优先)
trustedRemotePrefixes: ['10.144.144.0/24'] # 内网网段免密(IPv4 CIDR)
tokenTtlMs: 604800000 # 登录有效期,默认 7 天
① Recommended: DSH Settings → Plugin configuration → "Access authentication" card
Usage
- Passwordless by default: remote access (public domain / LAN IP) works directly.
- With a password: local
http://127.0.0.1:3080stays password-free; remote first visit is 302-redirected to the login page; logged-in sessions skip login for 7 days (configurable). - When nginx runs on the same host as DSH (remote is always 127.0.0.1 but Host is a domain), a password is still required — public traffic cannot bypass authentication.
- Login state lives in memory: a DSH restart requires re-login.
Optional configuration (override the auth-gate row in profiles/web/cordis.patch.yml)
- id: auth-gate
config:
# password: 'xxx' # optional: row-level password (highest priority)
trustedRemotePrefixes: ['10.144.144.0/24'] # password-free LAN CIDRs (IPv4)
tokenTtlMs: 604800000 # login TTL, default 7 days