Skip to content

feat(preview-auth): gate a preview to its base repo's GitHub readers - #32

Merged
luthermonson merged 1 commit into
mainfrom
feat/preview-auth-repo
Sep 10, 2026
Merged

luthermonson merged 1 commit into
mainfrom
feat/preview-auth-repo

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

Switchboard's half of per-preview GitHub-repo-read gating. For a gated preview, switchboard now writes one new key into the per-site [preview_auth] override: repo = "owner/name" — the preview's base repo full name. ePHPm's preview gate reads it and admits exactly the GitHub users with read access to that repo. (ePHPm reader is a separate coordinated PR.)

Contract (must match ePHPm)

[preview_auth]
session_secret = "env:EPHPM_PREVIEW_SESSION_SECRET"
login_url = "/_ephpm/auth/github/login"
repo = "owner/name"

Exactly owner/name, the base repo (never a fork's).

Changes

  • site_override.rs: PreviewAuthSection carries a validated repo. is_valid_repo_full_name enforces two non-empty [A-Za-z0-9._-] segments, single slash, no ./.. segment (also guarantees TOML-safety for the hand-rolled writer). render_override emits the repo line.
  • deployer.rs: resolve_preview_gate threads req.repo_full_name into the section, failing the deploy closed on a malformed base repo.
  • job.rs/webhook.rs: no change — base repo already reaches the builder via PreviewRequest.repo_full_name.

Not touched

Global github-auth mount, share-link path, secret model, should_gate (private still always gated).

Validation

cargo build, cargo test (268 pass), clippy -D warnings, fmt --check, MSRV +1.85 check — all clean. New tests: owner/name shape accept/reject, TOML-injection rejection, fail-closed on malformed base repo, render assertions; ungated preview still writes no [preview_auth].

Rollout

Forward-compat: ePHPm tolerates unknown [preview_auth] keys today, so writing repo is safe on nodes whose ePHPm predates the reader (ignored/warned until the consuming side lands).

Write the base repository full name (owner/name) into the per-site
[preview_auth] override section as a new `repo` key, so ePHPm's preview
gate can admit exactly the GitHub users with read access to that repo.

This is switchboard's half of the approved per-preview repo-read gating
contract shared with ePHPm: for a gated preview switchboard emits
`repo = "owner/name"` (the preview's BASE repo, never a fork's)
alongside `session_secret` and `login_url`.

- site_override.rs: PreviewAuthSection carries a validated `repo` field.
  is_valid_repo_full_name enforces the exact owner/name shape (two
  non-empty [A-Za-z0-9._-] segments, single slash), which also makes the
  value TOML-safe for the hand-rolled writer. render_override emits it
  inside [preview_auth].
- deployer.rs: resolve_preview_gate threads req.repo_full_name (the base
  repo, already populated from repository.full_name) into the section,
  failing the deploy closed if the base repo is not a clean owner/name.

The global github-auth mount, the share-link path, the secret model, and
should_gate are untouched (private is still always gated).
@ephpm

ephpm Bot commented Sep 10, 2026

Copy link
Copy Markdown

ePHPm Preview — removed

Preview deployment has been torn down.

@ephpm
ephpm Bot temporarily deployed to preview-pr-32 September 10, 2026 04:11 Inactive
@ephpm
ephpm Bot temporarily deployed to preview-pr-32 September 10, 2026 04:11 Inactive
@luthermonson
luthermonson merged commit 3bd7a9a into main Sep 10, 2026
4 checks passed
@luthermonson
luthermonson deleted the feat/preview-auth-repo branch September 10, 2026 04:12

This branch was previously deployed

1 inactive deployment
preview-pr-32 68306c37 Deployed Sep 10, 2026 by ephpm[bot]
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.

1 participant