daifuyang/dsh-plugin--plugins-auth0

dsh-auth-plugin

DSH 可选身份验证层插件:提供 Web 登录界面、命令行指令及工具执行权限门控。

AI 分析

核心用途是为 DSH 网页端添加密码登录墙,并对敏感工具的执行进行权限拦截。适合将 DSH 部署在公网或多用户共享环境、需要安全防护的用户。

套件
dsh-auth-plugin
版本
0.1.0
授權
MIT
最近更新
2026年8月15日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:daifuyang/dsh-plugin#a30db42814421e890a822f58dcc2c8ecb5ca94dd&path:plugins/auth

dsh-auth-plugin

Optional auth layer for dsh, packaged as a bundle per the publish tutorial.

Two halves, independent by design:

  • Browser wall: a server-side prefix route on / covers any visitor without a session cookie. The SPA HTML is served either way, but the page renders a Vercel-style login card injected right after `` when the cookie is absent. The user stays on the same URL (e.g. /sessions/abc) — there is no abrupt redirect to a separate /login page. Submitting the form posts to /auth/login; on success the server sets an HttpOnly cookie and the next navigation drops the overlay.

  • Agent gate: /login , /logout, and /whoami slash commands track per-Session auth state. A tools/pre-execute waterfall turns non-public tool calls into an ask decision until the Session is logged in. Public tools (read_file, list_directory, web_search, web_fetch) are always allowed without login.

The browser cookie and the agent Session state are deliberately separate: a logged-in browser does not log the agent in, and vice versa.

Install

pnpm dsh plugin --profile  add ./plugins/auth
pnpm dsh --profile 

Config

- id: auth
  name: dsh-auth-plugin
  config:
    requireLogin: true   # default; set false to disable the agent-side gate

Credential policy

The expected username and password are resolved per request from the credentials seam ($DSH_HOME/.credentials.yaml, then the process environment). When neither source supplies a value, the POC defaults dfy / 123456 are accepted. Harden by setting:

DSH_AUTH_USER=alice DSH_AUTH_PASSWORD='s3cret' pnpm dsh web

Known limitations and deferred work

  • Auth state is per-Session, not global; logging into one agent does not log into its subagents.
  • Browser cookie store is in-memory (Set), so a dsh restart logs everyone out. Persist to disk if you need that.
  • No CSRF token on /auth/login — the form accepts a same-origin POST and cookies are SameSite=Strict, but add a token if you ever expose this beyond loopback.
  • No /logout --all cross-session sweep yet.
  • SPA dist resolution depends on apps/web/dist/index.html being reachable from the bundle's real path — works in source-checkout; for installed distributions, publish a versioned @deepseek-ai/dsh-web-frontend so require.resolve finds it.