feat(web): mint scoped agent-binary install token, gate download endpoint (VS-60) #79

Merged
Claude-Run merged 1 commit from feat/VS-60-agent-install-token-endpoint into main 2026-06-26 20:29:55 +02:00
Member

Add GET /agentbinaries/install-token: a session-gated endpoint that mints a scoped, short-lived (5 min) agent-binary install token and returns it as JSON {"token": ""} so the vervain-apps enrollment dialog's mint_install_token deserializer consumes it unchanged. Returns 401 (no body) when the operator vervain_session cookie is absent or invalid. The enrollment flow was 404ing because this route did not exist (parent VS-54; the frontend dependency VAPP-35 shipped ahead of it).

Add the client-facing authorization VS-57 left unbuilt: agent_binary_download_handler (VS-56, /api/v1/agent/binary/:id) now authorizes BEFORE any upstream read, accepting EITHER a valid operator vervain_session (the admin browser button) OR a valid ?token= install token (the unattended device curl, which presents no cookie). Unauthorized requests get 401 with no binary bytes and no upstream detail.

The new InstallTokenStore mirrors control_token's in-memory, auto-GC design but is multi-use within its TTL (validate, not consume), since the same token is carried by both the operator-facing download button and the device-side curl. Scope and TTL are documented in the handler and store doc-comments.

Tests cover: mint with valid session (200 + non-empty token), mint without session (401), download with valid token (passes the auth gate), download with invalid/absent token (401), download with a session (still accepted), plus store mint/validate/expiry/multi-use units.

#VS-60

Add GET /agentbinaries/install-token: a session-gated endpoint that mints a scoped, short-lived (5 min) agent-binary install token and returns it as JSON {"token": "<value>"} so the vervain-apps enrollment dialog's mint_install_token deserializer consumes it unchanged. Returns 401 (no body) when the operator vervain_session cookie is absent or invalid. The enrollment flow was 404ing because this route did not exist (parent VS-54; the frontend dependency VAPP-35 shipped ahead of it). Add the client-facing authorization VS-57 left unbuilt: agent_binary_download_handler (VS-56, /api/v1/agent/binary/:id) now authorizes BEFORE any upstream read, accepting EITHER a valid operator vervain_session (the admin browser button) OR a valid ?token= install token (the unattended device curl, which presents no cookie). Unauthorized requests get 401 with no binary bytes and no upstream detail. The new InstallTokenStore mirrors control_token's in-memory, auto-GC design but is multi-use within its TTL (validate, not consume), since the same token is carried by both the operator-facing download button and the device-side curl. Scope and TTL are documented in the handler and store doc-comments. Tests cover: mint with valid session (200 + non-empty token), mint without session (401), download with valid token (passes the auth gate), download with invalid/absent token (401), download with a session (still accepted), plus store mint/validate/expiry/multi-use units. #VS-60
feat(web): mint scoped agent-binary install token, gate download endpoint (VS-60)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 2m43s
Create release / Create release from merged PR (pull_request) Has been skipped
c51fbd08c6
Add GET /agentbinaries/install-token: a session-gated endpoint that mints a scoped, short-lived (5 min) agent-binary install token and returns it as JSON {"token": "<value>"} so the vervain-apps enrollment dialog's mint_install_token deserializer consumes it unchanged. Returns 401 (no body) when the operator vervain_session cookie is absent or invalid. The enrollment flow was 404ing because this route did not exist (parent VS-54; the frontend dependency VAPP-35 shipped ahead of it).

Add the client-facing authorization VS-57 left unbuilt: agent_binary_download_handler (VS-56, /api/v1/agent/binary/:id) now authorizes BEFORE any upstream read, accepting EITHER a valid operator vervain_session (the admin browser button) OR a valid ?token= install token (the unattended device curl, which presents no cookie). Unauthorized requests get 401 with no binary bytes and no upstream detail.

The new InstallTokenStore mirrors control_token's in-memory, auto-GC design but is multi-use within its TTL (validate, not consume), since the same token is carried by both the operator-facing download button and the device-side curl. Scope and TTL are documented in the handler and store doc-comments.

Tests cover: mint with valid session (200 + non-empty token), mint without session (401), download with valid token (passes the auth gate), download with invalid/absent token (401), download with a session (still accepted), plus store mint/validate/expiry/multi-use units.

#VS-60
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/vervain-server!79
No description provided.