dsh-multiuser-keys: Each user uses their own Provider API Key when sharing a single Harness

Preface

In companies or teams, it is common practice to deploy a single DeepSeek Harness (DSH) instance as a web service for multiple people to share via browsers. Model invocations often need to connect to corporate gateways or various cloud providers, with credentials typically written in server environment variables or Harness configuration. The result is that quota and billing fall under the same set of keys, making it difficult for individuals to “use their own accounts and their own quota.”

The following introduces the community plugin dsh-multiuser-keys (package name @local/dsh-multiuser-keys, maintained by az13js, categorized under admin-security). It allows administrators to specify “which providers require users to provide their own keys.” Users fill in and save these in their browsers; the keys remain only on the user’s local machine and enter the server’s memory with the request for resolution without being persisted to disk. Providers not listed in the mapping still use Harness default credentials, facilitating future changes to unified company quota distribution.

What is this

dsh-multiuser-keys targets scenarios where “the same Harness instance is shared by multiple people”: each person uses their own provider API key to consume their respective account quota.

The plugin runs with the permissions of the current DSH process; please read the source code and license information in the repository before installing. The community directory is an independent site and has no official affiliation with DeepSeek / High-Flyer.

How it works (Summary)

  1. Browser: Keys are stored in localStorage; same-origin /api requests carry the header x-dsh-user-keys (content is base64url encoded JSON) and are not sent to third-party domains.
  2. Server Host Half (index.js): Reads the header at the HTTP layer, uses AsyncLocalStorage to record the key ring for the current request; wraps ctx.credentials.resolve(), intercepting only credential references (apiKeyEnv names) configured by the administrator, and delegating the rest to the native implementation.
  3. Server Client Half (client.js): Provides a configuration page under “Settings → My API Key”.
  4. Memory & Lifecycle: Keys on the server exist only in process memory (session-bound up to 512 entries + recent active key ring, valid for 30 minutes by default). After a restart or update, the user’s browser will automatically carry the keys on the next request without additional operation.

Core Features

  • Administrators configure which providers (e.g., llm-pi-ai routing names) require users to bring their own keys; unconfigured providers behave exactly as they would without the plugin installed.
  • The user-side settings page displays “Configured / Unconfigured” status for mapped providers; key inputs are masked by default. Changes take effect for the next request upon saving; clearing them reverts to server default credentials.
  • No new HTTP endpoints are added; it reuses the existing /api. It is compatible with --trusted-host and Nginx proxy_pass header passing (note: do not log headers containing keys in gateway logs).
  • Optional configuration: recentRingWindowMs, header, source, logResolutions, etc. (see Administrator Configuration section).

Installation & Activation

Prerequisite: pnpm is available on the target machine (required for the Harness plugin manager; if only corepack is available, use corepack enable pnpm or a shim like exec corepack pnpm "$@").

Place the plugin directory anywhere on the server (e.g., /opt/dsh-plugins/dsh-multiuser-keys), then choose one of the following:

Method 1 (Recommended): Install via the GUI plugin page, or call plugin_manager install_bundle via the Agent, passing the absolute directory path as target.

Method 2: Command-line equivalent operation:

dsh plugin --profile web add /opt/dsh-plugins/dsh-multiuser-keys

And append "@local/dsh-multiuser-keys" to the dsh.profile.bundles array in ~/.dsh/profiles/web/package.json.

You can also publish the package to a private company registry and install it by package name. The README states that this plugin has no install scripts and no npm dependencies, so installation will not trigger build scripts.

Kubernetes: The plugin must be installed under profiles/web/ within $DSH_HOME (default ~/.dsh) during the image build stage to avoid losing the plugin after Pod recreation. Example snippet:

COPY dsh-multiuser-keys /opt/dsh-plugins/dsh-multiuser-keys
RUN dsh plugin --profile web add /opt/dsh-plugins/dsh-multiuser-keys \
 && node -e "const f='/root/.dsh/profiles/web/package.json',fs=require('fs'),p=require(f);p.dsh.profile.bundles.includes('@local/dsh-multiuser-keys')||p.dsh.profile.bundles.push('@local/dsh-multiuser-keys');fs.writeFileSync(f,JSON.stringify(p,null,2))"

Administrator Configuration

Choose either method.

A. Written in the plugin row of the profile patch (see config.example.yml in the repo for complete examples):

- id: multiuser-keys
  name: "@local/dsh-multiuser-keys"
  config:
    providers:
      - provider: company-gateway
        label: Company LLM Gateway
      # - provider: openrouter
      #   ref: OPENROUTER_API_KEY

B. Independent JSON file (suitable for ConfigMap mounting):

- id: multiuser-keys
  name: "@local/dsh-multiuser-keys"
  config:
    configFile: /etc/dsh/multiuser-keys.json
{ "providers": [ { "provider": "company-gateway", "label": "Company LLM Gateway" } ] }

ref can be omitted: The plugin reads the apiKeyEnv for that provider from settings; providers that cannot be read will trigger a warning and be skipped. After changing the configuration, refresh the browser page; the provider catalog is delivered with the homepage HTML.

Typical Usage (User)

  1. Open Harness Web: Settings → My API Key (My API keys in English interfaces).
  2. Paste your own key for each mapped provider → Save.
  3. Send a conversation or task to confirm the billing path uses the personal key (requires provider mapping to be completed on the administrator side and the page to be refreshed).

Self-check (Host side):

node test/host.test.mjs

Uninstall: Use plugin manager remove_bundle @local/dsh-multiuser-keys; to clear keys in the browser, simply clear site data.

Scenarios & Notes

Suitable for: Single-instance containers or intranet Harness, shared by multiple people via Web, where some model routes are desired to use user-provided keys while the rest use unified server credentials.

Known Limitations (excerpt from README):

  1. When the same session is used by two people simultaneously, session binding defaults to the last request; there is no user-level session isolation—independent sessions are recommended.
  2. Desktop IPC, ACP/CLI, and other non-Web channels cannot inject browser keys; behavior is equivalent to being unconfigured.
  3. Background tasks without session context may use the “most recently active user’s” key within the recentRingWindowMs window; otherwise, they fall back to default credentials.
  4. The Models settings page still reflects server-side credential status; user key status should be based on this plugin’s settings page.
  5. The key trust boundary is the same as the same-origin page: any subject capable of executing scripts on the site can read localStorage.

The README notes that installation and Host tests were conducted on a local Harness (0.2.0-rc.2, web profile); actual saving in browsers, header round-trips, and billing paths after mapping need to be verified in your own environment.

Conclusion

dsh-multiuser-keys utilizes a “browser-stored keys + header injection + server-side resolution based on mapping” approach to split quota for specific providers to individuals without significantly altering the Harness deployment form. If you are maintaining a multi-user DSH, you can view the documentation and config.example.yml from the directory page and GitHub repository, then install and configure it following the steps above.

  • Directory Page: https://www.skillhub.cn/plugins/az13js/dsh-multiuser-keys
  • GitHub: https://github.com/az13js/dsh-multiuser-keys
羽毛球分组比赛记分
小程序二维码

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

Xiaoye