Repository navigation
Feat(remote): send a gateway's headers from ZENNOTES_REMOTE_HEADERS (ZenNotes/zennotes#1091) - #54
Merged
Merged
Conversation
…eaders (ZenNotes/zennotes#1091) A self-hosted server put behind an access gateway such as Cloudflare Access was out of reach for zn, zn tui and zn mcp. The gateway turns away every request that lacks its credentials (a service token is two headers, CF-Access-Client-Id and CF-Access-Client-Secret) before the server sees it, and zn could only send the server's own token. The desktop app gained these headers in its connect dialog (ZenNotes/zennotes 250e55b4), but it keeps them in the system keychain, which zn cannot read. zn now takes them from ZENNOTES_REMOTE_HEADERS: one `Name: value` per line, blank and `#` lines skipped, and the two characters `\n` count as a line break because an MCP client's JSON env block can carry nothing else. internal/remote/headers.go mirrors the desktop's shared parser rule for rule, so one value works in both: Authorization is refused (the token has its own flag and the server reads it as that token), so are the names the connection sets itself, and a list that does not parse fails every request with its line number before anything is sent, rather than going out in part and coming back as the gateway's bare 403. Every request through remote.Client carries them: JSON calls, raw reads, uploads, and the /api/watch handshake, without which the socket never opens. The three request paths now share one sender, which also names a gateway when it refuses: an HTML 403 (the ZenNotes server answers in plain text) or a redirect to a sign-in page on another host, instead of quoting the page or failing on a JSON parse. :version sends them too. What it deliberately leaves alone: the headers are never written to credentials.toml, which holds tokens and nothing else; the in-process client behind the server's own /mcp endpoint sends none, since the transport vouches for it; and the health check of a server zn manages locally talks to localhost, where no gateway sits. Tested: go vet and gofmt clean; go test ./... passes, with the desktop's parser cases ported and a stub gateway that 403s in HTML without both headers seeing them on JSON, raw, upload and WebSocket requests. Against a real server behind that gateway, the built zn is refused by name without the variable, lists the vault with it (real line break or `\n`), sends nothing on a malformed value, and zn mcp lists the gated note over stdio.
renovate Bot
added a commit
to scottames/copr
that referenced
this pull request
Nov 21, 2026
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ZenNotes/zennotes](https://redirect.github.com/ZenNotes/zennotes) | minor | `2.88.0` → `2.90.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/3) for more information. --- ### Release Notes <details> <summary>ZenNotes/zennotes</summary> ### [`v2.90.0`](https://redirect.github.com/ZenNotes/zennotes/releases/tag/v2.90.0): ZenNotes v2.90.0 [Compare Source](https://redirect.github.com/ZenNotes/zennotes/compare/v2.89.0...v2.90.0) ZenNotes 2.90.0 fixes a creation-date bug on Windows: a note you delete and make again under the same name now gets its own date instead of the deleted note's. The desktop app also bundles zn 0.18.1, which has the same fix, and renders math with KaTeX 0.19.1. Released from [`b1895548`](https://redirect.github.com/ZenNotes/zennotes/commit/b1895548261e5ed3550d76921daae1cb4f3cd500) through [#​1101](https://redirect.github.com/ZenNotes/zennotes/pull/1101) on 2026-11-20. #### Fixes - **A note made again under a deleted note's name gets its own date on Windows.** Windows keeps a deleted file's creation time for about 15 seconds and gives it to the next file created under the same name (NTFS calls this file system tunneling). ZenNotes read a new note's date from the file, so a note deleted and made again right away showed the old note's date, and its first save wrote that date down for good. Every way the app makes a note now records its creation date the moment it makes it: a new note or drawing, an Obsidian drawing conversion, an import, a duplicate, and notes the MCP server creates or duplicates. A note created outside ZenNotes still takes its date from the file. Temporary folder sessions are unchanged and still get no `.zennotes/` folder. - **Math renders with KaTeX 0.19.1.** The 0.16 line had a low-severity advisory ([GHSA-238p-pmpm-9mq7](https://redirect.github.com/advisories/GHSA-238p-pmpm-9mq7)): prototype pollution already present in a page could turn on KaTeX options the app leaves off. Formulas look the same; equation numbers, matrices, aligned blocks and struck math were checked in Edit and Preview. #### zn - **The desktop app bundles zn 0.18.1** ([ZenNotes/tui#55](https://redirect.github.com/ZenNotes/tui/pull/55)), which records a new note's date the same way, in `zn create`, `zn write`, `zn capture` and `zn mcp`. A desktop-managed `zn` already updates itself; this raises the version a fresh install starts from. #### Phones - **iPhone 1.43.0 and Android 1.1.62** carry the shared core of this release. The date fix is for Windows, so the one change there is math rendering with KaTeX 0.19.1. #### For contributors - **`startNoteCreation(root, rel)`** in `apps/desktop/src/main/note-creation-metadata.ts` is what a creation path calls now, instead of removing the sidecar. It writes `{version: 1, createdAt: now}` to `.zennotes/note-metadata/<rel>.metadata.json` atomically (fsynced temp file, then rename) and skips ephemeral roots. zn's `writeNoteFileAtomic` does the same when the note does not exist yet. - **Windows CI keeps the tests' scratch vaults on the runner's work disk.** `os.tmpdir()` on a Windows runner is on the C: system disk while the checkout is on D:, and one MCP task update fsyncs four files, which took a 25 ms test past vitest's 5 s limit on a slow runner. The Build job now points `TEMP` and `TMP` at `RUNNER_TEMP`. - **One KaTeX for the whole tree.** rehype-katex, micromark-extension-math and mermaid still ask for katex ^0.16.0, so a root `overrides` entry moves them to 0.19.1 with everything else. KaTeX 0.18 prefixed its internal classes: an equation number is `.katex-tag` now, not `.tag`. A custom theme that styled KaTeX internals needs the new names; `.katex` and `.katex-display` are unchanged. - **The ordered-list tests hand Enter the finished parse.** `ensureSyntaxTree` finishes the parse in the language state's context, but `syntaxTree(state)` keeps returning the tree the state was created with; an empty transaction (`state.update({}).state`) adopts the finished one. #### Verification How to test locally, on Windows: 1. Open a vault in ZenNotes and create a note named `Tunnel test`. Note the date in its info. 2. Wait a minute, then delete it permanently (empty it from the Trash). 3. Within 15 seconds, create a new note named `Tunnel test` and type a line. 4. Before: the new note showed the first note's creation date, and kept it after a save and a relaunch. After: it shows the moment you made it, and keeps that after a save and a relaunch. 5. The same with `zn`: `zn create --title "Tunnel test" --body first`, `zn delete "inbox/Tunnel test.md" --yes`, `zn create --title "Tunnel test" --body second`, then `zn list --limit 1 --json`: `createdAt` is the second create. #### Distribution channels - **GitHub:** this release, latest, with all five update feeds. Every file they name was checked, and the app in both macOS DMGs is Notarized Developer ID and stapled. - **AUR:** `zennotes-bin 2.90.0-1`, pinned to the Linux tarball's SHA-256 `b3dbcafd…99b525`. - **Homebrew:** the `zennotes` cask in ZenNotes/homebrew-tap (`d2baec7`). - **Nix:** `packaging/nix/release-data.json` (`aab158fc`), built on `main` (run [`4482970`](https://redirect.github.com/ZenNotes/zennotes/commit/44829703200)). - **nixpkgs:** [NixOS/nixpkgs#590905](https://redirect.github.com/NixOS/nixpkgs/pull/590905), now `zennotes-desktop: 2.88.0 -> 2.90.0`, waiting for nixpkgs review. - **Self-hosted server and Docker:** unchanged; server 2.84.1 is current. - **zn:** [0.18.1](https://redirect.github.com/ZenNotes/tui/releases/tag/v0.18.1), released first and bundled here; the Homebrew `zn` formula is on 0.18.1 too. - **Phones:** iPhone 1.43.0 is Waiting for Review on the App Store. Android 1.1.62 is in review on Google Play, and its [GitHub release](https://redirect.github.com/ZenNotes/zennotesandroid/releases/tag/v1.1.62) carries Play's signed universal APK. Both carry the shared core `core-2.90.0-core.h7d82a7cbcca39312`, published as a pre-release. - **Website:** the release page on zennotes.org, zn 0.18.1 on the CLI releases page, and the CLI version in the docs. #### Release validation - On `b1895548`: typecheck, every test suite uncached (shared-domain 2715, portable-vault 398, app-core 4949, quicklook 18, web 76, desktop 1964), `build:prod`, `npm run pack` and the packaged launch check (page target, rendered, 2.90.0, bundled zn 0.18.1), and the three smoke suites. No hazards, no audit findings at any level, no long dashes. - The creation-date fix has tests that fail on the old code, in the app, the MCP server and zn: each fakes NTFS tunneling by handing the recreated file the deleted note's birthtime. It was not run on a real NTFS disk. - The gate found two things before the cut. `npm audit` listed seven low findings, all one KaTeX advisory: KaTeX moved to 0.19.1 everywhere, and math was driven in the built app (inline, struck, numbered, matrices, aligned, underbrace; Edit and Preview) and on both phones. Then one app-core test timed out once under load (a hover preview measured at 190 ms against a 1 s wait); its wait is now 5 s. Every check ran again on the final commit. - Windows CI: with the tests' scratch files on the runner's work disk, Windows x64 passed on the first try on both runs of the release pull request and on `main`, the job that timed out on `main` after 2.89.0. - The phones were walked on the release builds before either store, fresh installs: iPhone 1.43.0 on an iOS 27.2 simulator and Android 1.1.62 on an emulator, with onboarding, a new note, the remote vault step and a note of math. The Android pull request's emulator job could not boot on a runner without hardware acceleration (twice), so the local walk stood in for it. The iPhone Cloud UI tests were skipped (no Cloud change). - Not tested before release: packaged Windows and Linux builds beyond CI, and the date fix on a real Windows disk. ### [`v2.89.0`](https://redirect.github.com/ZenNotes/zennotes/releases/tag/v2.89.0): ZenNotes v2.89.0 [Compare Source](https://redirect.github.com/ZenNotes/zennotes/compare/v2.88.0...v2.89.0) ZenNotes 2.89.0 reaches a self-hosted server behind Cloudflare Access or any other gateway that checks headers. The desktop app, `zn` and the MCP server send the gateway's credentials with every request, live updates included. The desktop app also bundles zn 0.18.0. Released from [`d500ea01`](https://redirect.github.com/ZenNotes/zennotes/commit/d500ea0134a148bc5214b1d258fe031e52cc517b) through [#​1097](https://redirect.github.com/ZenNotes/zennotes/pull/1097) and [#​1098](https://redirect.github.com/ZenNotes/zennotes/pull/1098) on 2026-11-20. #### Features - **Reach a server behind Cloudflare Access or another gateway** ([#​1091](https://redirect.github.com/ZenNotes/zennotes/issues/1091), asked for by [@​medzsikmisi](https://redirect.github.com/medzsikmisi)). An access gateway in front of your server turns away every request that does not carry its credentials, so nobody can reach ZenNotes at all without them. A Cloudflare Access service token is two such credentials, sent as headers. In Connect to Remote Vault, the Auth Token step now has **Add extra headers**: write one `Name: value` per line. ``` CF-Access-Client-Id: <client id>.access CF-Access-Client-Secret: <client secret> ``` Enter adds a line and Cmd/Ctrl+Enter connects. A remote you already saved takes the same box under Settings, Vault, Saved Remote Workspaces, Edit. The headers are stored in the system keychain with the auth token, never in `config.toml`, and Settings shows only their names afterwards. They go with every request, uploads and images included, and with the live-update connection, so edits from other devices still arrive at once. Keep your ZenNotes auth token in its own field: the gateway checks the headers, then the server checks the token. Any gateway that checks headers works the same way, for example a proxy that wants `X-Api-Key: <key>`. - **`zn` and the MCP server send them too.** They cannot read the keychain, so they take the same lines from `ZENNOTES_REMOTE_HEADERS`: the `zn` installed from Settings, CLI (`zn`, `zn tui` and `zn mcp`, from 0.18.0) and the copies bundled with the app. In an MCP client's JSON config, write the line break as `\n`: ```json "ZENNOTES_REMOTE_HEADERS": "CF-Access-Client-Id: <client id>.access\nCF-Access-Client-Secret: <client secret>" ``` A value that does not parse stops the command with its line number before anything is sent. #### Fixes - **A gateway that refuses says so.** When something in front of the server turns a request away (an HTML 403), or sends it to a sign-in page on another host, ZenNotes now names the gateway instead of showing its page or failing with a parse error. The ZenNotes server's own refusals keep their own words. #### zn - **The desktop app bundles zn 0.18.0**, which sends `ZENNOTES_REMOTE_HEADERS` on every request ([ZenNotes/tui#54](https://redirect.github.com/ZenNotes/tui/pull/54)). A desktop-managed `zn` already updates itself; this raises the version a fresh install starts from. #### Phones - **iPhone 1.42.0 and Android 1.1.61** carry the shared core of this release. Nothing changes on the phones themselves: their remote client does not send extra headers yet, so the box is hidden there. #### For contributors - **One parser decides what a header list is**, `packages/shared-domain/src/remote-headers.ts`, used by the connect dialog, by the main process (which re-reads whatever a renderer sends) and by the bundled `zn` and MCP server. zn's `internal/remote/headers.go` mirrors it rule for rule. Authorization is refused (the token has its own field), so are the names the connection sets itself, and a list that does not parse is dropped whole rather than sent in part. - **Headers are their own secret-store entry** per remote (`remote-workspace-headers:<id>`), beside the token. A renderer gets only their names back (`RemoteWorkspaceProfile.headerNames`). - **`supportsRemoteHeaders`** on the bridge capabilities hides the field where the host's remote client does not send headers (the phones, for now). - **`apps/desktop/src/main/remote/gateway-headers.test.ts`** runs a stub gateway that answers 403 in HTML unless both Cloudflare headers arrive, and checks JSON, asset, upload and change-feed requests. #### Verification How to test locally: 1. Run a ZenNotes server, and in front of it anything that refuses requests without a header. Cloudflare Access with a service token is the real case; a local stand-in is a small proxy that answers 403 unless `CF-Access-Client-Id` is set. 2. In ZenNotes, run Connect to Remote Vault (command palette), enter the gateway's URL, and on the Auth Token step enter the server's token only. Connect. 3. Before: the connection failed with a confusing error quoting the gateway's page. After: ZenNotes says that something in front of the server refused the request and points at the extra headers. 4. Run Connect to Remote Vault again, choose **Add extra headers**, write the header lines, and press Cmd/Ctrl+Enter. The vault opens. Edit a note on the server from another device: it shows up at once. 5. Quit and reopen ZenNotes: it reconnects through the gateway on its own. Settings, Vault, Saved Remote Workspaces, Edit lists the saved header names, never their values. 6. In a terminal: `ZENNOTES_REMOTE_HEADERS=$'CF-Access-Client-Id: <id>\nCF-Access-Client-Secret: <secret>' zn list --server <gateway url> --token <token>` lists the vault; without the variable, `zn` names the gateway. #### Distribution channels - **GitHub:** this release, latest, with all five update feeds. Every file they name was checked, and the app in both macOS DMGs is Notarized Developer ID and stapled. - **AUR:** `zennotes-bin 2.89.0-1`, pinned to the Linux tarball's SHA-256 `611d845d…436971`. - **Homebrew:** the `zennotes` cask in ZenNotes/homebrew-tap (`fc75354`). - **Nix:** `packaging/nix/release-data.json` (`abf115d4`), built on `main` (run [`4477292`](https://redirect.github.com/ZenNotes/zennotes/commit/44772925985)). - **nixpkgs:** [NixOS/nixpkgs#590905](https://redirect.github.com/NixOS/nixpkgs/pull/590905), `zennotes-desktop: 2.88.0 -> 2.89.0`, waiting for nixpkgs review. The previous bump to 2.88.0 merged. - **Self-hosted server and Docker:** unchanged; server 2.84.1 is current. - **zn:** [0.18.0](https://redirect.github.com/ZenNotes/tui/releases/tag/v0.18.0), released first and bundled here; the Homebrew `zn` formula is on 0.18.0 too. - **Phones:** iPhone 1.42.0 is Waiting for Review on the App Store. Android 1.1.61 is in review on Google Play, and its [GitHub release](https://redirect.github.com/ZenNotes/zennotesandroid/releases/tag/v1.1.61) carries Play's signed universal APK. Both carry the shared core `core-2.89.0-core.hf590792c335f6b1a`, published as a pre-release. - **Website:** the release page on zennotes.org, the Cloudflare Access guide in the docs, and zn 0.18.0 on the CLI releases page. #### Release validation - On `d500ea01`: typecheck, every test suite uncached (shared-domain 2715, portable-vault 398, app-core 4949, quicklook 18, web 76, desktop 1961), `build:prod`, `npm run pack` and the packaged launch check (page target, rendered, 2.89.0), and the three smoke suites. No hazards, no audit findings, no long dashes. - The headers were driven end to end against a stub gateway that answers 403 in HTML unless both Cloudflare headers arrive: connect, reopen, live changes, assets and uploads, and `zn` with `ZENNOTES_REMOTE_HEADERS`. - The gate found two things before the cut. The custom themes watcher could report a change after it was stopped, which surfaced as an unhandled rejection in its test; fixed, with a test that fails on the old code. Four moderate production advisories (hono, [@​hono/node-server](https://redirect.github.com/hono/node-server), fast-uri, ip-address) were bumped. Every check ran again on the new commit. - After the go, CI on `main` failed on Linux arm64: the same watcher could still report from a folder read already in flight when it stopped. That was fixed too (`d500ea01`, reports now need the watcher to still be current), every check ran again, and `main` passed on every platform at `d500ea01` before the tag. - On the fix's pull request, the Windows x64 runner failed three times on tests unrelated to the change: an ordered-list test that reads a parse its setup never stores (a test bug, fixed next release), then disk-heavy tests timing out on a slow runner. `main` passed Windows at the tagged commit. - CodeQL flagged a one-line `.replace` in a test fixture; it was dismissed as test-only. - The phones were walked on the release builds before either store: Android 1.1.61 on an Android 17 emulator and iPhone 1.42.0 on an iOS 27.2 simulator, fresh installs, with onboarding, a note on disk and the one-field Auth Token step. The Android pull request's emulator job could not boot on a runner without hardware acceleration, so the local walk stood in for it. The iPhone Cloud UI tests were skipped (no Cloud change). - Not tested before release: packaged Windows and Linux builds beyond CI, and a real Cloudflare Access deployment (the stub gateway stands in for it). </details> --- ### Configuration 📅 **Schedule**: (in timezone America/Los_Angeles) - Branch creation - Every minute (`* * * * *`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/scottames/copr). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuMyIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets zn,
zn tuiandzn mcpreach a ZenNotes server behind an access gateway such as Cloudflare Access (ZenNotes/zennotes#1091), matching desktop 2.89.0, which gains the same headers in its connect dialog.Extra headers come from
ZENNOTES_REMOTE_HEADERS: oneName: valueper line; blank and#lines skipped; the two characters\ncount as a line break for JSON env blocks.internal/remote/headers.gofollows the desktop's shared parser rule for rule:Authorization and the headers the connection sets itself are refused.
At most 20 headers, no duplicates, no control characters.
A value that does not parse fails every request with its line number before anything is sent.
Every
remote.Clientrequest carries them: JSON, raw reads, uploads, and the/api/watchhandshake. The three request paths now share one sender.A gateway refusal (an HTML 403) or a redirect to a sign-in page on another host is named as a gateway instead of quoted or failing on JSON.
:versionsends them too. They are never written tocredentials.toml; the in-process client behind the server's own/mcpand the local managed-server health check send none.zn --help, the TUI help and the README document the variable, with a Cloudflare example.Tested:
go vetandgofmtclean;go test ./...passes. New tests port the desktop's parser cases and run a stub gateway that 403s in HTML without both headers, which sees them on JSON, raw, upload and WebSocket requests. Against a real server behind that gateway, the built zn is refused by name without the variable, lists the vault with it (real line break or\n), sends nothing on a malformed value, andzn mcplists the gated note over stdio.