Repository navigation
fix(auth): stop another account denying a device sign-in it did not approve - #2938
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The Evidence section says
Suggested fix: No diff — add the recording under Evidence or link to it from the Evidence section. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Quick104
left a comment
There was a problem hiding this comment.
Review of 2b928db. The fix is right: deny now follows the same first-approval-holds rule as approve, the conditional UPDATE closes the race with a second account's approval, and the new DB test fails on main when its Deny calls are adapted to the old signature. I found one low-severity regression and some stale contract text. I'm fixing all of them in a commit on this branch, so there's no need to change anything yourself.
One item outside the diff: contracts/api/v2/migration.json (denyDeviceLogin retry_safety_note) still says the denial is UPDATE ... WHERE status IN (pending, approved), and the deny.approved scenario description in gen_auth.py and api-v1-auth.json still says a deny "overrides the approval" without saying it has to come from the approving account. Both get updated in the same commit.
…pprove Deny cleared any approved request, so a second account holding the code could cancel a TV sign-in someone else had approved before the TV collected it. Deny now refuses such a request with 409 approval_conflict, as approve already does; the approving account can still withdraw its own approval.
Deleting the approving profile or account sets approved_by_user_id NULL and leaves the request approved but uncollectable. The new deny check refused that row for everyone; treat a NULL approver as deniable again. Also name the v2 problem code in the device-login architecture doc, state approve-handoff's profile-level rule in auth-api.md, and update the deny retry note and deny.approved scenario text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2b928db to
094f8d8
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summary (reviewed 2b928db, fixes pushed as 094f8d8)The fix holds. Deny now refuses a request another account approved, as approve already did, and the conditional Addressed in 094f8d8 (the branch was rebased onto current main, so its history was rewritten):
Left for maintainers: no contract scenario covers the new 409 on deny. Only the Go DB test pins it. A Tests: Cross-provider review: gpt-6.1-sol (xhigh) reviewed 2b928db and found nothing. Validated features: no passed case on the v1.0 board touches device sign-in. User manual: unaffected. The TV sign-in page doesn't describe deny or approvals from another account. Apple/Android parity: none needed. This is a server-side authority check. Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) Fit: it closes a real authority gap in device sign-in at the service that owns the rule, matches approve's existing behavior, and adds no new surface. Readiness: the behavior is shown by a test that fails without the fix, and the one edge case it opened is fixed and covered. |
|
The Evidence section now shows before-and-after API responses, but this change is a multi-step device sign-in flow. Add a short recording of one account approving, another attempting to deny, and the device still receiving the approval; identify the surface and build or commit. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Problem
Closes #2897
Related issue: N/A
Validation tasks: none affected
Once one account approved a TV's device sign-in, a second account holding the
same code could still deny it before the TV collected its tokens. The deny
replaced the approval, so the TV saw
deniedand never signed in. Approvealready refuses a second account with 409
approval_conflict; deny did not.Deny now refuses it the same way, so the first approval holds.
The approving account can still deny its own approval to withdraw it before the
device collects it. Anyone can still deny a request that is pending, or one
whose approving account or profile was deleted, since the device can no longer
collect it.
Approach
DeviceLoginService.Denynow takes the deciding account. If the request isapproved by a different account it returns
ErrDeviceLoginConflict, which theshared decision handler already maps to 409
approval_conflict. TheUPDATEcarries the same condition, so a deny that races a second account's approval
also gets 409 and does not overwrite it.
The handler is shared by
/api/v1and/api/v2deny, so both change. 409 isalready a documented deny response on both, and the change fails closed, so it
fits the v1 rule that only critical fixes land there. The v2 OpenAPI document
and fixtures do not change. Jellyfin Quick Connect has no deny route.
docs/architecture/device-login.md("Who decides") anddocs/auth-api.mddescribe the rule. The
deny.any_accountanddeny.approvedscenario text inthe v1 auth catalog and the deny retry note in
contracts/api/v2/migration.jsonsaid any deny overrides an approval; they now state the new rule. Recorded
expectations are unchanged.
Validation
Deny: a second account's deny is refused and the TVstill collects the approval. The approving account's own deny withdraws it.
An approval whose approving account or profile was deleted can still be
denied by any account. It runs in CI's "Test device sign-in against Postgres"
step. It failed before the fix.
go testforinternal/auth(with Postgres, including-raceon the devicesign-in tests),
internal/api/handlersandinternal/apiv2: pass.internal/scenariocatalog/executor(frozen v1deny.approved,deny.any_accountand the refusals): pass. Other cases inTestRequiredDeviceDecisionsAcceptance, all poll and session checks, failthe same way on
main, so this change did not cause them.make lint-changed,gofmt,goimports,make verify-local-paths: clean.Evidence
The visible change is in the device sign-in flow: once account A approves a TV's sign-in code, account B's deny no longer cancels it. These responses come from the real
/api/v2handlers and device login service, run in-process against a local Postgres with two real accounts. Before ismainatbe6527e50; after is this branch at53e9f602a. Codes and tokens are redacted.A starts the device request with
POST /api/v2/auth/device/start, then approves it withPOST /api/v2/auth/device/approve, which answers200 {"status":"approved"}on both. Then B denies the same code:Risks
A client that let a different account deny an approved request now gets 409.
The web activate page already treats 409 on deny as "the request moved on" and
reloads it.
Checklist
AI Disclosure
Note
Fix cross-account device login denial with ownership check in
DeviceLoginService.DenyDeviceLoginService.Denynow takes the denier's user ID. It rejects an approved request when a different linked account approved it, and returnsErrDeviceLoginConflict(device_login.go).auth.AuthHandler.DenyDeviceLoginpasses the authenticated user ID through to the service (auth_device.go).Denyno longer lets any account deny a live approval owned by another account; the SQL update only accepts approved requests whose approver is null or matches the denier.Macroscope summarized 094f8d8.