From 7bb0172a641606e27ffde47333baab69f43f86be Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:09:46 -0500 Subject: [PATCH 1/7] docs: Telegram approval flow, mark ntfy and WebAuthn not in the stage 2 path Stage 2 notifies via Telegram (PR #40) with buttons and a no-login view link (#41) that shows decoded content and named extra fields (#42, #43). Verified against approval/mod.rs, approval/page.rs and config.rs on origin/main. Docs only. --- README.md | 2 +- docs/design/muse-gated-passthrough.md | 10 ++++++---- docs/design/webauthn-approval.md | 2 +- docs/runbooks/muse-stage2.md | 15 +++++++++------ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6f99f55..c5cde4d 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ and `deploy/muse/pilot-policy.example.toml`. Stage 2 adds a third verdict, `hold`, for writes the owner wants to approve one by one. A held request keeps its connection open. The gate tells the owner a request is waiting (a fixed text and a link, never -the content), the owner opens a separate approval page, and only an explicit approve forwards the request. +the content; with `[notify] buttons = true` the Telegram message also has Approve and Deny buttons and a no-login view link), the owner decides on the approval page or, with buttons, in Telegram, and only an explicit approve forwards the request. Deny, expiry (`hold_secs`), a caller who gives up, a policy reload that drops the identity, and shutdown all end the request with a refusal and nothing sent upstream. The connection is the state: there is no queue, and a restart forgets every held request. diff --git a/docs/design/muse-gated-passthrough.md b/docs/design/muse-gated-passthrough.md index 582c882..9b79345 100644 --- a/docs/design/muse-gated-passthrough.md +++ b/docs/design/muse-gated-passthrough.md @@ -451,7 +451,9 @@ owner's phone through a second `tailscale serve` mapping on its own port, never port; the ACL shape is in section 4.2 [A]. A local CLI over a Unix socket remains a fallback. The HTTP API is client-agnostic (`GET /pending`, `GET /pending/`, `POST /pending//approve|deny`), in line with the #6 decision that app shells are thin clients over the same endpoints [I issue #6 comment 1]. -WebAuthn approval over the digest is a later replacement for the credential step [I issue #6 comment 1]. +WebAuthn approval over the digest is a later replacement for the credential step [I issue #6 comment 1]. WebAuthn is a design only (`docs/design/webauthn-approval.md`), not implemented. + +Current state: with `[notify] buttons = true` the owner decides in Telegram with Approve and Deny buttons, and the message carries a no-login one-time view link (PR #41). The Basic-auth page and CSRF code remain and are used when `buttons = false`; they are not the primary path. Page controls: @@ -549,7 +551,7 @@ and `view_base_url`. `buttons = false` restores option C (3.6.1) with no code ch compared in constant time. It is valid only while the entry is `Pending`. Approve, deny, expiry, drop, abandon and supersede each end it at once. An unknown or ended token gets the same generic 404 bytes as an unknown path. The page is read-only and shows the redacted request that the approval page shows - (method, route, redacted path, body preview, header names, with credential values hidden). It has the + (method, route, redacted path, header names, with credential values hidden). It shows the decoded message content (PR #42) and a banner naming any other top-level fields, names only (PR #43); the raw body is in a closed Details block. It has the six hardened headers, sets no cookie, has no form and no CSRF token, and never logs or audits the token. The route exists only when buttons are on. - **Supersede in buttons mode.** A supersede sends one new notification for the newest entry. The @@ -889,7 +891,7 @@ those exists because the caller does not wait. Here the caller waits, so the rea | Audit transitions `held/approved/denied/expired/executed` | **Keep**, rename `executed` to `forward_started` and `completed` | Same purpose; the record precedes the action | | Expiry as a recorded terminal refusal, not a state | **Keep** | Matches the connection model directly | | Single execution | **Keep** as at-most-once per connection (section 5.1) | In-memory state machine, no store | -| WebAuthn approval | **Defer** | Part of the end state in #6. The PoC uses Basic auth plus a per-page CSRF token | +| WebAuthn approval | **Defer** (not implemented) | Part of the end state in #6. The PoC uses Basic auth plus a per-page CSRF token | | Durable pending store surviving restart | **Drop** | The connection is the state. A restart loses it and that is the specified behaviour | | "Consume approval and mark executed in one durable write" (restart-safe exactly once) | **Drop** | Nothing to recover. After a restart there is no approved id to re-execute | | Request id and polling endpoint, callback | **Drop** | The response is the connection's own response. The request id remains, as an audit and approval-page key only | @@ -1220,7 +1222,7 @@ Open questions 1 to 4 are stage 1 blockers. 6. **Retry behaviour.** (Answered [M-reported] for the 423, 410 and 503 probes and a real 423 `no_grant` write: no retry; see `docs/evidence/muse-stage1.md`.) After an `expired` or `denied`, does Muse's agent retry automatically? If so each retry is another phone prompt; dedupe, the per-identity cap and the default 60 s cooldown bound this. 7. **Approver channel.** Answered in the review comments: Basic auth plus a per-page CSRF token for the PoC, - WebAuthn later, and the approval API stays client-agnostic (a requirement). The notifier is Telegram only + WebAuthn later (design only, not implemented), and the approval API stays client-agnostic (a requirement). The notifier is Telegram only (section 3.6.1, owner decision 2026-11-21). 8. **One caller key per what?** One identity per Muse user, per connector, or per Discord channel set? This sets how revocation and the audit identity read. diff --git a/docs/design/webauthn-approval.md b/docs/design/webauthn-approval.md index e54aa50..7ccdd51 100644 --- a/docs/design/webauthn-approval.md +++ b/docs/design/webauthn-approval.md @@ -1,6 +1,6 @@ # WebAuthn approval bound to the held request -Status: design note, no code. Revision 3 answers the review verdicts at 96c10923 (section 16) and the re-review at 62e4364 (section 17). Draft for the standing design review; not final. Issue: +Status: design only, not implemented (no WebAuthn code on main). The stage 2 notifier is Telegram (PR #40), not ntfy, so the ntfy passages below are superseded; the current approval flow is in `docs/design/muse-gated-passthrough.md` section 3.6. Revision 3 answers the review verdicts at 96c10923 (section 16) and the re-review at 62e4364 (section 17). Draft for the standing design review; not final. Issue: [#37](https://github.com/openabdev/auth-proxy/issues/37). Based on `origin/main` at `3878421`. Builds on `docs/design/muse-gated-passthrough.md` (sections 3.4 to 3.9, 5.2, open question 7) and on the stage 2 implementation in draft PR [#29](https://github.com/openabdev/auth-proxy/pull/29), which is **in diff --git a/docs/runbooks/muse-stage2.md b/docs/runbooks/muse-stage2.md index 7630c0a..b14809e 100644 --- a/docs/runbooks/muse-stage2.md +++ b/docs/runbooks/muse-stage2.md @@ -2,7 +2,7 @@ Design: `docs/design/muse-gated-passthrough.md` (sections 3.4 to 3.9, 5, 7 stage 2). Stage 2 adds the `hold` verdict, the approval listener and a notification hook to the stage 1 passthrough. Everything -here is generic: use your own hosts, and never commit real host names, addresses, logins, topics or keys. +here is generic: use your own hosts, and never commit real host names, addresses, logins or keys. **The gate constrains the agent, not the Muse platform.** Muse's egress holds the real Discord token, so Muse or anyone who compromises it can call Discord directly and skip the gate. @@ -97,7 +97,9 @@ Run these yourself. Do not paste the token into chat, a ticket, a commit or this The file path goes in `[notify] token_file`. Keep mode 0600 and no group or other bits. No other user may read it. 5. Restart `auth-proxy`. A startup error line `notify token file: ...` names only the kind of fault. 6. Send a test hold from the Muse side. The owner's chat should receive one message with the fixed - sentence, a request id and a link. Open the link and approve or deny. + sentence, a request id and a link. With `buttons = false`, open the link and approve or deny on the + approval page. With `buttons = true` (3.2), press Approve or Deny in Telegram; the link opens a read-only + view. To rotate the token, revoke it in BotFather (`/revoke`), write the new token to the same file, and restart. Anyone who has the token can send messages as the bot and read `getUpdates` for it, so treat it like a @@ -119,8 +121,8 @@ Do these in addition to 3.1. Run each one yourself and keep the answers out of c listener's `/view/` path. Use an https name, not the Muse caller name. 4. Restart `auth-proxy`. A startup error names the missing or refused key and nothing else. 5. Send one test hold. The message should have the fixed sentence, the id, the view link and the two - buttons. Open the link on the tailnet and read the request. Press Approve or Deny in Telegram. The - button should stop spinning and reply `Approved` or `Denied`. Press it again: the reply should be + buttons. Open the link on the tailnet: the view page shows the decoded message content and names any + other fields. Press Approve or Deny in Telegram. The button should stop spinning and reply `Approved` or `Denied`. Press it again: the reply should be `No longer waiting`. 6. To go back to option C, set `buttons = false` and remove `owner_chat_id` and `view_base_url`. Restart. The view route then disappears, and the approval page is used as before. @@ -133,8 +135,9 @@ ownership for a press. The approval listener binds loopback. Put it behind a front that only the approver can reach, on a different name and path from the one Muse uses, and keep the approval port off the caller path. This is a -deployment control; the code cannot prove it. The approver authenticates with Basic auth plus a per-view, -single-use CSRF token. +deployment control; the code cannot prove it. With `buttons = false` the approver authenticates on the +approval page with Basic auth plus a per-view, single-use CSRF token. With `buttons = true` the owner +decides in Telegram, and the Basic-auth page is not the primary path. With `buttons = true`, the same front must also map `/view/` to the approval listener. That path needs no login, so only the tailnet may reach it. Never map it on a public name. From 986d6c888af4e4eab57291284f41fada7df1686e Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:09:51 -0500 Subject: [PATCH 2/7] docs: helper timeout applies to blocking routes only hold_secs max stays 5..=600 (config.rs); no 3600 or 1 hour hold text exists. The Option B pilot text already matches config.rs TokenIdentity (token_sha256, expires 2026-12-20, one per policy, hold-only, route-bound). Docs only. --- docs/design/muse-gated-passthrough.md | 4 ++-- docs/runbooks/muse-stage2.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/design/muse-gated-passthrough.md b/docs/design/muse-gated-passthrough.md index 9b79345..76adc16 100644 --- a/docs/design/muse-gated-passthrough.md +++ b/docs/design/muse-gated-passthrough.md @@ -1039,7 +1039,7 @@ Acceptance: stage 2 does not start until they are answered. Results: `docs/evidence/muse-stage1.md`. Stage 2 prerequisites from those results: - - The connector's helper timeout for gated routes must exceed the hold window (the default 30 s is not enough). + - The connector's helper timeout for gated routes must exceed the hold window (the default 30 s is not enough). This applies to blocking routes only; an async route returns 202 at once (`muse-async-poll.md`). - The connector for the gate host must be the agent's only route to Discord; remove the old connector or unregister its credential before the gate is relied on. @@ -1203,7 +1203,7 @@ Open questions 1 to 4 are stage 1 blockers. 300 s through the TLS front (no cut up to 300 s); helper side [M-reported], the Muse helper received each completed response end to end with its timeout raised above the hold, and the default 30 s helper timeout gave up on a 30 s hold. Hard condition: the default 30 s helper timeout is not enough, so the - helper timeout for gated routes must exceed `hold_secs`. Still unmeasured: any ceiling above 300 s, and + helper timeout for gated routes must exceed `hold_secs` (blocking routes only; it does not apply to an async route). Still unmeasured: any ceiling above 300 s, and the platform-internal swap logs. The 120 s default for `hold_secs` is within the observed range, only with the raised helper timeout. See `docs/evidence/muse-stage1.md`. 2. **Caller-key header name.** Answered [M-reported]: the current helper cannot add a custom request header, diff --git a/docs/runbooks/muse-stage2.md b/docs/runbooks/muse-stage2.md index b14809e..e4d4ca0 100644 --- a/docs/runbooks/muse-stage2.md +++ b/docs/runbooks/muse-stage2.md @@ -144,9 +144,9 @@ login, so only the tailnet may reach it. Never map it on a public name. ## 5. Timeouts and the old connector -- The connector's helper timeout must be longer than `hold_secs`, and so must every idle timeout between +- For blocking routes the connector's helper timeout must be longer than `hold_secs` (max 600), and so must every idle timeout between Muse and the gate (the TLS front, any load balancer). The effective window is the smallest of them. - Measure it before relying on a long `hold_secs`. + Measure it before relying on a long `hold_secs`. This does not apply to an async route. - Remove the previous direct connector once the gate is the only path, or the agent can still write without approval. From e73d04eb3ce1218681aac42b31de8f4e351c65dd Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:10:24 -0500 Subject: [PATCH 3/7] docs: async polling design matches code (per-route keys, string body), link from gated passthrough --- docs/design/muse-async-poll.md | 11 ++++++----- docs/design/muse-gated-passthrough.md | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/design/muse-async-poll.md b/docs/design/muse-async-poll.md index 96463c2..aef5304 100644 --- a/docs/design/muse-async-poll.md +++ b/docs/design/muse-async-poll.md @@ -1,8 +1,9 @@ # Muse async poll for held writes -Draft. Terms follow `muse-gated-passthrough.md` 3.4 and 4.5. +Status: implemented on main (#45); operator steps are in `docs/runbooks/muse-stage2.md`. Terms follow `muse-gated-passthrough.md` 3.4 and 4.5. ## Scope -Only the Muse route `POST /channels/*/messages` (held), per route. Config key `muse.hold_mode = -blocking|async` (default `blocking`); `async_hold_secs` applies only in `async`. Else unchanged. +Only the Muse route `POST /channels/*/messages` (held), per route. Config keys on the `[[route]]` table: `hold_mode = "blocking"|"async"` (default `blocking`) and +`async_hold_secs` (5..=600, default 120, used only in `async`). Async needs a passthrough route with a hold +grant; otherwise the policy is refused at load. Else unchanged. ## POST 1. Write the `held` audit record first. On failure refuse 503 `audit_unavailable`, before any entry exists and before any notification. @@ -25,7 +26,7 @@ anything else is 400, without revealing whether the token exists. Response is `p | `denied`, `expired`, `dropped`, `send_failed` | 200 | `status`, `request_id` | | `send_unknown` | 200 | `status`, `request_id`, `error_class` (`reset`, `timeout`, `write_failed`) | -`body` is at most 64 KiB, `truncated=true` if cut. The token is read-only and never approves, denies +`body` is a string (the Discord response as lossy UTF-8 text, which the caller parses itself), at most 64 KiB, `truncated=true` if cut. The token is read-only and never approves, denies or changes state. A final status stays readable for a fixed 60 s window starting at the final transition (for `approved_and_sent`, when the Discord response is fully read or cut at 64 KiB). After that, and for any unknown token, the response is a uniform 404. No retained-entry cap. @@ -54,7 +55,7 @@ current shape and never carry a token, `Authorization`, hash or body. Unapproved ## Departures Connection-as-state is replaced for this route. No cancel on Muse disconnect. Discord response headers are not returned verbatim. `X-AP-Decision` is not returned after admission. Fingerprint dedupe and supersede do not apply. -Owner confirmation of these four departures is needed before implementation. +These departures are as implemented. ## Tests Poll after each final status; uniform 404 after the window and for unknown tokens; `send_unknown` path; restart loses pending entries; audit shape with no token in audit. diff --git a/docs/design/muse-gated-passthrough.md b/docs/design/muse-gated-passthrough.md index 76adc16..37396e0 100644 --- a/docs/design/muse-gated-passthrough.md +++ b/docs/design/muse-gated-passthrough.md @@ -1,8 +1,9 @@ # Muse gated passthrough: a hold-the-connection approval gate Status: stage 1 is implemented and measured. Stage 2 (held-connection approval) is implemented on -branch `feat/muse-stage2` and tested in CI against a mock upstream; it is not deployed, and the -through-the-front measurements (hold window, disconnect signal) are still open. Scope: a minimal proof +main (merged) and tested in CI against a mock upstream; the through-the-front measurements (hold window, +disconnect signal) are still open. Asynchronous polling is also implemented on main, see +[muse-async-poll.md](muse-async-poll.md). Scope: a minimal proof of concept (PoC) for one consumer, Muse calling the Discord HTTP API through auth-proxy in standalone service mode. See "Stage 2 implementation notes" at the end of section 7 for where the code differs from this text. @@ -43,7 +44,8 @@ Stated by the owner and treated as fixed [A owner]: (section 3.5). Discord's own responses, including any `x-ap-*` headers they carry, pass through unchanged. 6. The connection is the state. There is no durable approved state, no polling endpoint and no one-time - proof. A crash after approval and before forwarding loses the held connection, nothing executes, and + proof. (For a route with `hold_mode = "async"` this is replaced: the POST returns 202 and the caller + polls, see [muse-async-poll.md](muse-async-poll.md). Nothing is durable there either.) A crash after approval and before forwarding loses the held connection, nothing executes, and Muse's retry starts a new approval round. ## 2. Overview @@ -462,10 +464,10 @@ Page controls: - `approve` and `deny` are form `POST`s. A browser sends Basic credentials automatically, so each page carries a per-page CSRF token (random, bound to the entry id, single use) that the POST must echo. - Every approval response, including errors, carries `Content-Security-Policy: default-src 'none'; - frame-ancestors 'none'; form-action 'self'`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, + style-src 'sha256-'; frame-ancestors 'none'; form-action 'self'`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `Cache-Control: no-store`, `Pragma: no-cache` and `X-Content-Type-Options: nosniff`. `default-src` does not cover `frame-ancestors`, so it is named, which stops a page framing the approve button over the - owner's cached Basic credentials. The page has no script and no inline style, and renders the body and + owner's cached Basic credentials. The page has no script and no `style` attributes; its one inline `