Skip to content

Whitelists via environment variables + CI trigger fix - #4

Merged
barrydeen merged 2 commits into
bitvora:masterfrom
r0d8lsh0p:env-whitelists-upstream
Aug 31, 2026
Merged

barrydeen merged 2 commits into
bitvora:masterfrom
r0d8lsh0p:env-whitelists-upstream

Conversation

@r0d8lsh0p

Copy link
Copy Markdown
Contributor

Hi Barry, thanks for merging #3 I appreciate it — this is the second of the two PRs mentioned there. It adds one small feature for your consideration: supplying the whitelists via environment variables. It builds on the merged migration and follows the same conventions (tests, e2e mode, README section).

This is a very useful feature for people who deploy to hosting services like Railway (e.g. me) as it allows edit read/write lists as env vars in the hosting service rather than in the json/code. I believe this is consistent with the approach taken by you for all your other Khatru relays.

What is this PR

  • Adds optional WRITE_WHITELIST_PUBKEYS / READ_WHITELIST_PUBKEYS env vars — comma-separated hex pubkeys that take precedence over the corresponding JSON whitelist files. Useful on hosted platforms (Railway, Fly, etc.) where per-environment config lives in env vars rather than files.
  • A one-line CI fix: the push trigger now only fires on master/main, so PR branches don't run the workflow twice (push + pull_request).

Behaviour

  • A variable with at least one entry wins over its JSON file; whitespace around entries and trailing commas are ignored.
  • When a variable is unset, blank, or contains only commas/whitespace, the file is used exactly as before — zero change for existing deployments.
  • Fail-closed by design: a blank variable falls back to the file rather than becoming an empty ("allow everyone") whitelist, so an accidentally empty env var can't open the relay. The "empty list = allow everyone" behaviour remains expressible only via the files, deliberately.

No breaking changes

No database, dependency, or file-format changes; file-based configuration is untouched.

Testing

  • unit: TestWhitelistsFromEnv — env wins over files for both lists, blank var falls back, commas/whitespace-only var falls back, env works with no file present
  • e2e: a new -env mode for the existing harness — env-listed keys can read/write while file-listed keys are rejected (priority), and blank vars fall back to the files. The existing -matrix / -open / -legacy modes now scrub these vars from the environment first, so ambient shell state can't contaminate the file-based checks.
  • CI: the -env mode runs as a fourth e2e step alongside the existing three (this PR's pull_request checks run it)
  • all green locally: unit + integration tests and all four e2e modes

Thank you for your consideration

Best regards

Rod

r0d8lsh0p and others added 2 commits August 25, 2026 15:35
Comma-separated hex pubkeys in WRITE_WHITELIST_PUBKEYS /
READ_WHITELIST_PUBKEYS take precedence over the JSON whitelist files,
for hosted platforms where per-environment config lives in env vars.

A set-but-blank variable falls back to the files rather than becoming
an empty (allow-everyone) whitelist, so an accidentally empty variable
fails closed. Covered by unit tests and a new e2e -env mode, wired
into CI alongside the existing three modes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pushes to PR branches were triggering both the push and pull_request
workflows, running CI twice per change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@barrydeen
barrydeen merged commit 7d99b01 into bitvora:master Aug 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants