GRI-1912: approve route leaves the token for the device to collect #126

Merged
vivy merged 3 commits from fix/GRI-1912-approve-leaves-token-to-device into dev 2026-11-11 04:28:59 +00:00
Owner

Fixes #123 (second cause; PR #125 fixed a real but different problem).

Cause

POST /api/v1/devices/{id}/approve (devices/handlers.rs) called devices::issue_token itself and returned the token in the admin's HTTP response. issue_token is one-shot per row (token_hash IS NULL). So when the device then reconnected with its temporary id, ws.rs handle_temporary_reconnect found the token already taken and answered Rejected: already enrolled on another connection — on every approval through the panel, not as a race. The client log in #123 matches: no connection ever logged Accepted, because the token went to curl/the panel.

The enrolment tests did not catch it because they approve with devices::approve_pending directly, not through the route.

Change

  • The approve route only approves. The device collects its identity and token on its next reconnect, as plan/server/enrolment.md "On approval" says. Response is {"device": {...}}, has_token: false until the device reconnects.
  • Test approving_a_pending_device_leaves_the_token_for_the_device: after the route, issue_token still returns a token for the device.
  • rest-api.md, deployment.md and the panel's type comment updated. The panel never read the token, so nothing changes there.

Checked here

cargo fmt --check, cargo clippy -p server --all-targets -D warnings, and devices_integration + devices_acceptance_integration + enrolment_acceptance_integration against local Postgres: 24 passed. Full local-gates.sh not run; CI is the gate. End-to-end proof: the next mvp-smoke-test.sh run (#115).

Fixes #123 (second cause; PR #125 fixed a real but different problem). ## Cause `POST /api/v1/devices/{id}/approve` (`devices/handlers.rs`) called `devices::issue_token` itself and returned the token in the admin's HTTP response. `issue_token` is one-shot per row (`token_hash IS NULL`). So when the device then reconnected with its temporary id, `ws.rs` `handle_temporary_reconnect` found the token already taken and answered `Rejected: already enrolled on another connection` — on every approval through the panel, not as a race. The client log in #123 matches: no connection ever logged `Accepted`, because the token went to curl/the panel. The enrolment tests did not catch it because they approve with `devices::approve_pending` directly, not through the route. ## Change - The approve route only approves. The device collects its identity and token on its next reconnect, as `plan/server/enrolment.md` "On approval" says. Response is `{"device": {...}}`, `has_token: false` until the device reconnects. - Test `approving_a_pending_device_leaves_the_token_for_the_device`: after the route, `issue_token` still returns a token for the device. - `rest-api.md`, `deployment.md` and the panel's type comment updated. The panel never read the token, so nothing changes there. ## Checked here `cargo fmt --check`, `cargo clippy -p server --all-targets -D warnings`, and `devices_integration` + `devices_acceptance_integration` + `enrolment_acceptance_integration` against local Postgres: 24 passed. Full `local-gates.sh` not run; CI is the gate. End-to-end proof: the next `mvp-smoke-test.sh` run (#115).
GRI-1912: approve route leaves the token for the device to collect
Some checks failed
CI / cargo fmt (pull_request) Successful in 17s
CI / the pre-push hook (pull_request) Successful in 18s
CI / cargo deny advisories (pull_request) Failing after 1m0s
CI / cargo deny (pull_request) Successful in 1m0s
CI / repository boundary (pull_request) Successful in 10s
CI / frontend-web (pull_request) Failing after 5m15s
CI / cargo clippy (pull_request) Successful in 10m11s
CI / cargo test (pull_request) Successful in 11m51s
CI / CI (pull_request) Failing after 6s
CI / Notify gate failed (pull_request) Successful in 7s
e3874da8de
The REST approve route called issue_token itself and returned the token
in the admin's HTTP response. The row issues one token only, so the
device's next reconnect with its temporary id always found it taken and
was refused as 'already enrolled on another connection' (signage #123).
The device now collects its token on that reconnect, as ws.rs expects.
GRI-1912: prettier format of approveDevice
Some checks failed
CI / the pre-push hook (pull_request) Successful in 15s
CI / cargo fmt (pull_request) Successful in 15s
CI / cargo deny advisories (pull_request) Failing after 1m10s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 10m30s
CI / frontend-web (pull_request) Successful in 10m1s
CI / cargo test (pull_request) Successful in 11m47s
CI / cargo deny (pull_request) Failing after 15m38s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
1d088c3c5a
GRI-1912: re-run CI (cargo deny job hit its 15-minute timeout)
Some checks failed
CI / cargo fmt (pull_request) Successful in 17s
CI / the pre-push hook (pull_request) Successful in 20s
CI / cargo deny (pull_request) Successful in 1m15s
CI / cargo deny advisories (pull_request) Failing after 1m12s
CI / repository boundary (pull_request) Successful in 16s
CI / cargo clippy (pull_request) Successful in 10m7s
CI / frontend-web (pull_request) Successful in 9m53s
CI / cargo test (pull_request) Successful in 11m51s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 4s
1666f36ffd
vivy merged commit c789d2be85 into dev 2026-11-11 04:28:59 +00:00
vivy deleted branch fix/GRI-1912-approve-leaves-token-to-device 2026-11-11 04:29:02 +00:00
Sign in to join this conversation.
No reviewers
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
Grimoirix/grimoire-of-digital-signage!126
No description provided.