dsh-trusted-proxy-auth: Bridging Reverse Proxy OIDC and DSH Native Browser Authentication

Preface

When placing DeepSeek Harness (DSH) behind reverse proxies such as Traefik and Keycloak, identity verification is often already completed at the proxy layer; if only DSH’s native browser launch-token / cookie flow is still relied upon, the remote access experience will be inconsistent with local loopback and SSH tunnel access. Rewriting OIDC/JWT directly inside DSH would touch the core installation and transport layer.

Below we introduce the community plugin dsh-trusted-proxy-auth (maintainer lukepoo101, category admin-security): under the premise that the proxy has already authenticated, it establishes a second independent authentication path via a private request header; when the header is missing or incorrect, the native DSH authentication behavior remains unchanged.

What Is This

dsh-trusted-proxy-auth is a small DSH plugin intended only for host-machine deployment (MIT license, current release version v0.2.3). It does not replace DSH transport, does not patch files inside the DSH installation directory, nor does it implement OIDC/JWT logic — it only adapts the authentication boundary to “proxy already logged in + injected shared secret” and “DSH-native 401/403 semantics”.

Typical chain diagram:

External browser
      │
      ▼
   Traefik ───────────► Keycloak OIDC
      │  (identity, login, roles, sessions)
      │
      │  injects:  X-DSH-Proxy-Auth: <private secret>
      ▼
     DSH ─────────────► trusted-proxy-auth
      │                  401 native browser auth + valid secret ──► permit
      │                  403 Host/Origin fence                   ──► still 403
      ▼
  native DSH transport, unchanged

When X-DSH-Proxy-Auth is absent (e.g., SSH tunnel or direct access), the native ?token=… / cookie flow is still used.

Core Features

Dual-Path Authentication Without Rewriting 403

The plugin hooks into DSH Web service’s requestRejection() (used for /api and the WebSocket mux) and the homepage’s authorizeIndex(). Key points:

Scenario Shared secret Result
Upstream is already 403 (Host/Origin/DNS-rebinding fence) Valid Still 403
Upstream 401 (native browser authentication required) Valid Permitted
Secret missing or incorrect — Native 401 preserved or delegated to the original flow

At startup, it re-validates DSH’s 403/401 semantics using invariants, preventing the plugin from silently becoming a bypass after DSH upgrades. Documented as tested and passing on DSH 0.1.5-rc.2, Node v24.21.0 (Node 20/22 covered by CI); 86 unit tests and 37 live-DSH integration checks pass. No npm dependencies at runtime, using only node:crypto, pure ESM, no build step.

Settings Persistence Under a Remote Hostname (ownsHost)

When accessing via a public hostname through a reverse proxy, the client may be determined by isLoopback to use in-memory persistence, and Models/Plugins configurations show “settings are unavailable in this browser”. For requests carrying a valid proxy authentication header, the plugin injects a server-side-validated bootstrap into the <head> of the index HTML via extension points such as webServer.tapIndex, so that the connection bundle treats ownsHost as true, thereby enabling 'host' persistence — without modifying the Node ServerResponse pipeline.

Third-Party Plugin Routing and Loopback Normalization

Some plugins (the README uses dshmarket@1.65.1 as an example) perform strict loopback checks on mutation-type HTTP routes. Under a public Host, simply rewriting Origin at the proxy layer would weaken CSRF protection. When a valid X-DSH-Proxy-Auth is present, the plugin first calls the undecorated connection.requestRejection(req) on the real inbound headers; if the Host/Origin fence is not passed it immediately returns 403; only after passing does it perform safe loopback normalization on match/handle routes, making plugins such as Marketplace usable behind a proxy.

Installation and Activation

1. Generate and write the shared secret

The secret must be at least 32 bytes of printable ASCII (excluding commas); do not write it into YAML — only place it in the environment file already read by the DSH service (example path /etc/dsh/env, owner root:dsh, mode 0640):

openssl rand -hex 48
SECRET="$(openssl rand -hex 48)"
printf 'DSH_PROXY_AUTH_SECRET=%s\n' "$SECRET" | sudo tee -a /etc/dsh/env >/dev/null
sudo chown root:dsh /etc/dsh/env
sudo chmod 0640 /etc/dsh/env

The reverse proxy side must be configured with the same-named logic: inject the request header X-DSH-Proxy-Auth only on requests from the internal network that have already completed OIDC etc. identity verification (value identical to the secret in the environment variable). This header should not be sent down to the browser.

2. Install the plugin and restart the service

After installing the bundle in the Web profile, restart DSH (authentication boundary plugins are recommended to be pinned to an audited tag or commit, do not track main):

# from a Git checkout
dsh plugin --profile web add /path/to/dsh-trusted-proxy-auth

# or directly from this repository, pinned to the released tag
dsh plugin --profile web add git+https://github.com/lukepoo101/dsh-trusted-proxy-auth.git#v0.2.3

# an exact commit is equally acceptable for an authentication-boundary plugin
dsh plugin --profile web add git+https://github.com/lukepoo101/dsh-trusted-proxy-auth.git#<40-char-commit>

sudo systemctl restart deepseek-harness

3. Verify the profile and public hostname

Confirm that the composed profile contains this plugin besides the Connection transport:

dsh web --dump-config | grep -E -A1 "connection|trusted-proxy-auth"

Expected fragment similar to:

- id: connection
  name: '@deepseek-ai/dsh-client-connection'
...
- id: trusted-proxy-auth
  name: dsh-trusted-proxy-auth

Write the final external hostname into the DSH startup parameters:

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

The specific routing, middleware, and header injection for Traefik + Keycloak OIDC need to be consistent with your infrastructure; the README only specifies the DSH-side environment variable and header name, and does not expand on proxy configuration templates here.

Configuration Description

Item Location Description
DSH_PROXY_AUTH_SECRET Environment variable Required. Missing, empty, too short, or illegally formatted causes plugin activation to fail; the profile cannot start in a half-on/half-off state.
X-DSH-Proxy-Auth Request header Injected only by the reverse proxy; do not expose it to clients.

The plugin itself has no YAML configuration items. Both openssl rand -hex 48 or openssl rand -base64 48 satisfy the character set requirements.

Applicable Scenarios and Cautions

Suitable for: Already connected to Keycloak OIDC behind Traefik (or another trusted reverse proxy), wanting remote browser sessions to be treated as authenticated by DSH while retaining the native token/cookie fallback for SSH tunnels and local loopback; and needing to use Models, Plugins persistence, and Marketplace-type plugins normally under a public hostname.

Be sure to note:

  • The plugin runs with the same privileges as the current dsh process; before installation, review the source code and the MIT license yourself. A leaked secret is equivalent to forging an authenticated request (still subject to the Host/Origin 403 constraints, but it cannot replace proxy-layer OIDC hardening).
  • The shared secret should only exist in the server-side environment and proxy configuration, not in the frontend or public repositories.
  • Authentication boundary plugins should be pinned to a version (e.g., v0.2.3 or a specified commit); when upgrading, deliberately bump it and re-run verification (see the repository’s docs/VALIDATION.md).

The DSH ecosystem emphasizes “everything is a plugin”; the community catalog SkillHub plugin page and the GitHub repository are maintained by the community, with no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-trusted-proxy-auth splits “the proxy has completed OIDC” and “DSH native browser authentication” into two independent paths: when X-DSH-Proxy-Auth is valid, it passes through a 401 while respecting the 403 fence; otherwise the behavior is identical to having the plugin not installed, and it also accommodates remote settings and strict loopback plugin compatibility.

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

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

Xiaoye