Automating a DSH plugin's local admin API (e.g. POST http://
Domain: dsh · Evidence E1 — Maintainer reviewed
dsh-auth--base64url-sha256-authoritypayload.secretautomating

Summary

Automating a DSH plugin's local admin API (e.g. POST http://:9655/api/our-free-model/providers) from a script fails with {"error":"unauthor…

Problem

Automating a DSH plugin's local admin API (e.g. POST http://<REDACTED:private_ip>:9655/api/our-free-model/providers) from a script fails with {"error":"unauthorized"} — the endpoint is mounted on DSH's own web server and curl with no credentials is rejected before the plugin's route handler runs.

Root Cause

DSH's connection carrier authenticates every request with a host-only, HttpOnly, SameSite=Strict cookie named dsh-auth-<base64url(sha256(authority))>. The cookie value is v1.<base64url(JSON payload)>.<base64url(HMAC-SHA256(secret, body))> where payload = {version:1, authority:"<REDACTED:private_ip>:9655", issuedAt, expiresAt} (ms epoch) and the HMAC secret is the base64url-decoded payload.secret of the client-connection/browser-session grant record in ~/.dsh/.credentials.yaml. No [REDACTED:bearer_token] is accepted (query tokens only work at the root index exchange).

Fix

Mint the cookie in the calling script: parse .credentials.yaml for the browser-session record's [REDACTED:credential] line, base64url-decode it (must be 32 bytes), build the v1 payload JSON with the exact authority (host:port you connect to), HMAC-SHA256-sign the base64url body, and send Cookie: dsh-auth-<name>=v1.<body>.<sig>` on every request to <REDACTED:private_ip>:9655. Plugin routes under /api/* then behave exactly as the settings page sees them — GET reads and POST writes both work, and config writes hot-reload into the running plugin without an app restart.

Verification

GET /api/our-free-model/summary with the minted cookie returns HTTP 200 with the plugin's JSON state; without it the same request returns {"error":"unauthorized"}.

GET /api/our-free-model/summary on 127.0.0.1:9655 with the minted cookie returns 200 JSON; the same request without the cookie returns {"error":"unauthorized"}.