Self-hosted platform: derive the R2 upload keys from the runtime API token
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 34/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- github, typescript
Rechercherichtung
Start with platform-lifecycle.ts, platform-management.ts, and platform-installer-secrets.ts; trace how runtime tokens and R2 credentials reach createPlatformInstallationSecrets and installPlatform. Check the token verification flow against platform/packages/api/src/email/cf-customer.ts and add coverage for both fallback directions, fresh installs, and token rotation. Done means derived credentials follow the specified precedence and recovery rules, with the docs updated and the Cloudflare token ID and presigned PUT behavior verified.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
A self-hosted platform install asks for two extra pasted values on a separate
Cloudflare page: the R2 Access Key ID and Secret Access Key
(packages/void/src/cli/platform-lifecycle.ts, the R2 block after the GitHub
OAuth prompts; page platformSetupPages(plan).r2 in platform-setup.ts).
The keys are only used by the API Worker to presign direct-to-R2 asset PUTs
(platform/packages/api/src/routes/deploy.ts presignAssetPut,
platform/packages/api/src/r2-presign.ts). They are not checked at install time,
so a wrong pair only fails at the first void deploy --platform void that
uploads assets (packages/void/src/cli/direct-r2-upload.ts, raw
R2 PUT failed for <path> (<hash>): 403).
Cloudflare documents that an API token can act as an S3 key pair:
Access Key ID = the token ID, Secret Access Key = SHA-256 hex of the token value
(https://developers.cloudflare.com/r2/api/tokens/). The runtime token already
has Account → Workers R2 Storage → Edit, and the API Worker already holds it as
CF_API_TOKEN, so deriving the pair adds no new permission to any Worker.
Proposed design
fresh interactive or CI install
runtime token verified ──▶ GET /user/tokens/verify (fallback /accounts/:id/tokens/verify)
──▶ r2AccessKeyId = result.id
r2SecretAccessKey = sha256hex(runtime token)
explicit VOID_PLATFORM_R2_ACCESS_KEY_ID + _SECRET_ACCESS_KEY pair still wins
upgrade / repair with a new VOID_PLATFORM_RUNTIME_CLOUDFLARE_API_TOKEN
recovery r2SecretAccessKey == sha256hex(recovery cloudflareApiToken)? (or no recovery)
yes ──▶ derive again, update R2_* Worker secrets together with CF_API_TOKEN
no ──▶ keep the separately supplied pair
PlatformCloudflareClient.apiTokenId(accountId): token-verify lookup, returns a
non-empty id without whitespace, otherwise throws.platform-installer-secrets.ts:platformR2SecretFromToken,
platformR2KeysFollowRuntimeToken(recovery),platformR2CredentialsFromRuntimeToken.- Lifecycle: remove the R2 page and both prompts; derive after the runtime token
is verified. platform-management.ts: derive on runtime-token rotation when the saved
pair was derived from the previous token.- Docs: credentials.md (R2 section), ci.md (R2 rows optional), maintenance.md
(rotation replaces derived keys; recreating the API needs R2 values only for
a separate R2 token), development/runtime.md (drop R2 from needed inputs).
Problems to fix in this design before implementing
- Order in
platform-management.ts: the keys cannot be derived both before
createPlatformInstallationSecretsand after the runtime-token preflight, because
the preflight (resolvePlatformRuntimeTokenToPreflight(plan, secrets)) reads the
result ofcreatePlatformInstallationSecrets. Derive before
createPlatformInstallationSecretsand leave the preflight where it is; the
token-verify call already rejects an invalid token. - Token-ID lookup order: trying account verify first and falling back only on
401/403/404 is not enough. What/accounts/:id/tokens/verifyreturns for a user token is
unverified (it may be 400). Match
platform/packages/api/src/email/cf-customer.tsverifyToken(user verify
first, then account verify), or fall back on any 4xx except 429. Rethrow 5xx.
Test both fallback directions. - Precedence on a non-draft resume:
configured()in the lifecycle returns
values[key] || envwhencredentialSetupis false. Reading the env pair first
in every mode flips that; withexistingInstallationand no
updateExistingWorkers, the live API Worker keeps its old R2 secret while
recovery saves the env pair, and later hash matching compares the wrong value.
Apply the env pair only whencredentialSetupis true; otherwise keep the
checkpoint values. - "Set both or neither": a new error for a half-set env pair can break a resume
that works today (one variable set, the other from the checkpoint). Apply the
check only on a fresh install (credentialSetup).
Tests this design needs: derived values reach createPlatformInstallationSecrets
and installPlatform on a fresh interactive install (token id from a spied
apiTokenId, secret = sha256 of the runtime token); the half-set env pair
error; upgrade with a rotated runtime token updates R2_ACCESS_KEY_ID /
R2_SECRET_ACCESS_KEY only when the saved pair was derived.
Unverified before merge
/user/tokens/verifyor/accounts/:id/tokens/verifyreturnsidfor an
account-owned runtime token (cfat_…), and a presigned PUT signed with the
derived pair succeeds on the e2e account.- Without recovery data, a rotation would also rewrite a separately supplied
pair. It keeps working (the runtime token has R2 Edit), but it changes
"only supplied values replace live credentials"; docs must say so.
Related, separate
An install-time R2 key check would also catch a wrong pasted pair before the
first deploy (today it surfaces as a raw 403 from direct-r2-upload.ts).
🤖 Generated with Claude Code
- Vorherrschende Sprache
- TypeScript
- Sterne
- 402
- Forks
- 32
- Ø Merge
- 12 Std. 28 Min.
- Gemergte PRs (30 T.)
- 77
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus voidzero-dev/void
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
voidzero-dev/void#478 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
voidzero-dev/void#463 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
voidzero-dev/void#459 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
voidzero-dev/void#428 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
voidzero-dev/void#480 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in voidzero-dev/void
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
521xueweihan/HelloGitHub#4025 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Small-tailqwq/dsh-deep-whale#207 ·
Maintainer antworten meist innerhalb von 1 Tag
-
The inspector never shows the instances field, so scaling out is unreachableEvtl. vergeben @Mrkewl hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
xevrion/breakscale#96 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Flux159/mcp-server-kubernetes#384 ·
-
Object parameters lose their structure when resources is enabledEvtl. vergeben @asts-top hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 2 Tagen