dsh-login-gateway: Add TOTP Login to the DeepSeek Harness Web UI

Preface

By default, the DeepSeek Harness (DSH) Web UI authenticates via a process startup token. This mechanism is convenient for local development, but once the port is exposed to the public internet, anyone holding the token can directly access the Harness, creating a security risk. The dsh-login-gateway plugin adds a gateway in front of the Web UI that performs username/password authentication plus TOTP second-factor verification, without modifying the Harness core code.

What is it

dsh-login-gateway is a plugin for DeepSeek Harness (DSH), maintained by developer ButterHost69 and licensed under MIT. It listens on its own port, provides a standard login page, and forwards traffic to Harness after successful authentication, thereby avoiding directly exposing unauthenticated APIs.

Core features

  • Independent listening and routing: Listens on its own host and port and provides /login, /logout, and /_dsh-login-gateway/health endpoints.
  • Multi-factor authentication: Verifies username, scrypt-hashed password, and TOTP code, and issues its own HMAC session cookie.
  • Traffic forwarding: Forwards authenticated requests (including WebSocket upgrades) to Harness and preserves the browser-side Host header.
  • Server-side token exchange: Completes the exchange from Harness startup token to cookie on the server side; the browser never touches sensitive credentials.
  • First-time initialization: When no account is configured, automatically provides a setup interface, generates a TOTP secret, and stores credentials.
  • Rate limiting: Limits failed login attempts separately per client address and per username.

Installation and activation

Before installation, ensure the environment meets the requirements: dsh version 0.2.1-alpha.1 or a compatible version, Node.js version ^22.19 || >=24, and the dsh web web profile is already started.

Install from GitHub (it will be built automatically):

dsh plugin --profile web add -w github:ButterHost69/dsh-login-gateway

If you are using pnpm >= 10, it may reject running build scripts for git dependencies due to the default security policy. If installation fails, add the allowBuilds configuration to the web profile’s pnpm-workspace.yaml:

allowBuilds:
  dsh-login-gateway: true

Then run the add command again.

Typical usage

After installation, the plugin is in first-run mode and you need to set up the first account in a browser.

  1. First-time setup: Visit http://127.0.0.1:8080/login (or access a link with ?setup=... via a tunnel).
  2. Create an account: Enter a username and password. The username must start with a letter and contain 2–32 lowercase letters, digits, or hyphens; the password must be at least 12 characters.
  3. Bind TOTP: After submitting, a TOTP secret and an otpauth:// URI will appear. Add them to an app such as Google Authenticator.
  4. Add more users: For reproducible deployments or to add users later, use the script provided by the plugin to generate configuration and write it to $DSH_HOME/profiles/web/cordis.patch.yml:
   cd /path/to/dsh-login-gateway
   npm install
   npm run build
   node scripts/enroll.mjs --username alice

Fill the resulting passwordHash and totpSecret into the users list in cordis.patch.yml.

  1. Expose the service: Point your tunnel or reverse proxy to the gateway port (default 8080) instead of the Harness port. For example, using Caddy:
   harness.example.com {
     reverse_proxy 127.0.0.1:8080
   }

When starting Harness, add the --trusted-host argument to allow external Host headers:

   dsh web --trusted-host harness.example.com

Use cases and notes

  • Use cases: When you need to access the DSH Web UI via a reverse proxy on the public internet or an intranet and require strong authentication.
  • Privilege risks: This plugin runs with the permissions of the current DSH process. It is recommended to review the source code and license (MIT) before installation.
  • TLS handling: The gateway itself only handles HTTP; TLS termination should be done at the reverse proxy (such as Caddy, Nginx, or Cloudflare Tunnel).
  • Host header dependency: The reverse proxy must preserve the browser-side Host header and forward WebSocket upgrade headers; otherwise, the Harness API will return 403.

Brief conclusion

dsh-login-gateway provides a standardized login entry for DSH and resolves the pain point of security issues caused by public exposure. For more configuration details and source code, see the details on GitHub.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye