feat(web): authorize agent-binary download endpoint (VS-57) #80
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VS-57-authz-agent-binary-download"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Authorizes the public agent-binary download endpoint
GET /api/v1/agent/binary/:id(VS-56). It shipped with no client-facing authz, leaving the streamed binary an open distribution point; the parent epic VS-54 requires authorization before it is exposed publicly.How
install_tokenmodule:InstallTokenStore, an in-memory store of opaque, URL-safe, TTL'd tokens bound to the minting operator's userid, modeled oncontrol_token(VS-32). Multi-use within a 10-minute window (not single-use like the control token) so the operator's browser download button and the unattended device-sidecurland its retries all present the same token from one enrollment.agent_binary_download_handlerauthorizes before any upstream read: accept the operatorvervain_sessioncookie (browser "Download agent" button) OR a valid?token=install token (devicecurl, which carries no session); otherwise 401 with no body and no Forgejo fetch. No per-id permission beyond authentication, so 401 is the only failure mode.Scope split
This is the enforcement half plus the token primitive. The token-minting HTTP endpoint the enrollment flow calls (
GET /agentbinaries/install-token) is the separate, linked VS-60. VS-57 is safe to land first: the only consumer of the public route is the enrollment dialog (which cannot render until VS-60), and the legacy/vervainagents/:idagent self-update path is a different, intentionally unauthenticated route this change does not touch.Tests
Full
just pre-commitgate green (fmt, clippy-D warnings, workspace check, 445 lib tests).Acceptance criteria (VS-57)
Closing as superseded.
While this PR was open, VS-60's PR #79 (
feat(web): mint scoped agent-binary install token, gate download endpoint, commitc51fbd0) merged intomainand implemented the same authorization this PR adds, plus the mint endpoint:install_token::InstallTokenStore(opaque, in-memory, TTL'd, multi-use) - equivalent to this PR's module, withvalidate()in place ofverify()and a 5-minute TTL.agent_binary_download_handlergated before any upstream read: operatorvervain_sessionOR a valid?token=install token, else 401 with no bytes - the same model this PR documents.GET /agentbinaries/install-tokenmint route (the VS-60 half this PR deliberately left out).So
mainis a superset of this branch; the merge conflict is two near-identicalinstall_token.rsfiles and duplicate handler gating. There is nothing here to land thatmaindoes not already have. All four VS-57 acceptance criteria are satisfied onmainby PR #79.Verified against
origin/mainHEADc4f09a4this turn (git show origin/main:crates/vervain-web/src/lib.rsandinstall_token.rs).Pull request closed