Repository navigation
feat(remote): approve and deny SiloRemote handoffs through v2 - #362
Conversation
|
Warning Review limit reachedNext included review available in 7 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3adc9ff05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard await TokenStore.shared.currentOrdinaryRequestAuth(matchingIdentityOf: auth) != nil else { | ||
| throw SiloControlHandoffError.identityChanged | ||
| } |
There was a problem hiding this comment.
Tear down the TV identity after a late owner change
When the owner changes after approval is dispatched but before handoff_ready arrives, this guard throws only after the TV has installed the temporary credentials. The catch then cannot send its fenced deny, and closing the control connection does not clean up the installed scope: handleConnectionClosed only calls cancelPendingHandoff, while the TV has already cleared its pending task, and its ready timeout exits once the connection ID changes. The stale identity can therefore survive and be reused by a later handoff from the same controller; explicitly tell the TV to end the activated identity or make disconnect tear it down.
Useful? React with 👍 / 👎.
| guard let auth = await TokenStore.shared.captureOrdinaryRequestAuth(), auth.accessToken != nil, | ||
| ServerRegistry.serverIdsMatch(auth.account.serverId, server.id), | ||
| auth.profileId == profileId else { | ||
| throw SiloControlHandoffError.identityChanged |
There was a problem hiding this comment.
Recheck the owner before accepting a reused ready
The captured owner is checked again only on the challenge/approval path. If the TV already holds an identity, .ready returns directly, so a credential generation or profile proof can change during offeredEndpoints, offer delivery, or the wait while the active server and profile IDs remain unchanged; the phone then launches through the TV's identity from the old owner. Apply currentOrdinaryRequestAuth(matchingIdentityOf:) before returning from the reused-ready branch as well.
Useful? React with 👍 / 👎.
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings, all fixed on this branch:
Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
05bbc97 to
8fda12a
Compare
f3adc9f to
711abc6
Compare
8fda12a to
a45cbbe
Compare
Sending a title to a TV still looked up, approved and denied the TV's remote-playback request through /api/v1/auth/device, with only a check that some access token existed. The handoff now captures the request owner (account, credential, profile and profile proof) before offering the profile, and reads, approves and denies the request through the shared APIv2Client's GET /api/v2/auth/device, POST /api/v2/auth/device/approve-handoff and POST /api/v2/auth/device/deny. Both calls take the captured owner, so a changed profile proof refuses the approval before it is sent, and the ready frame is accepted only while that owner still holds. The v1-only DeviceApproveRequest body is gone and DeviceLookupResponse is no longer decoded from the wire. Stack-PR: W5-D Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
711abc6 to
8d5ea7e
Compare
…734) After a seek or a resume into densely typeset ASS, AetherEngine's embedded subtitle drain fell behind the playhead, so signs stayed missing until the passage ended, and at the start of a file they arrived about 1.5 s late. Pin the fork to 87f85740 (Silo-Server/AetherEngine#20), which lets a text drain catch up in one tick and stops the #362 hole hold from firing on re-harvest seams the forward prefetch has read. The pin also brings in AetherEngine#18: a paused seek on the software path shows the target frame. The notices list AetherEngine#18 and #20, and the CI selector's build-input snapshot and seal are refreshed for the revision line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The iPhone now looks up, approves and denies a TV's SiloRemote handoff through
/api/v2/auth/device*, under the owner it captured when it offered the profile. A profile re-verified mid-handoff can no longer approve under the old owner.Problem
When the iPhone sends a title to a TV over SiloRemote, it approves the TV's temporary remote-playback sign-in on the server. That approval still used
/api/v1/auth/device(lookup),/api/v1/auth/device/approve-handoffand/api/v1/auth/device/deny(inventory rows 19, 20 and 21). Its only ownership check was that some access token existed.Solution
SiloControlClient.prepareRemoteIdentitycaptures the request owner (CapturedOrdinaryRequestAuth: account, credential owner, profile, profile proof) before sending the offer. It refuses to start if that owner does not match the target server and profile.SiloAPI.shared.apiV2Client:deviceLookupcallsGET /api/v2/auth/device, thendecideDeviceLogin(approveHandoff: true)callsPOST /api/v2/auth/device/approve-handoff(with the requiredX-Profile-Id). A failed handoff callsdecideDeviceLogin(approveHandoff: false), which sendsPOST /api/v2/auth/device/denyon a best-effort basis.APIv2Clientmethods take an optionalexpectedAuth.HTTPClient.requestDatacompares it withsameCredentialIdentity, so a changed credential or profile proof stops the lookup, approval or deny before it is sent. The TV'shandoff_readyis accepted only whilecurrentOrdinaryRequestAuth(matchingIdentityOf:)still matches.decideDeviceLoginnow requires 200 before it decodes the body (I2).client_purpose == "remote_playback",temporary == true) is now the testableSiloControlClient.isRemotePlaybackHandoff.DeviceApproveRequest.DeviceLookupResponseis no longerCodable, because nothing decodes it from the wire; pairing and the handoff build it fromAPIv2DeviceLookup.presentation.Contract (server
84ed9e596):approveDeviceHandoffisprofile_scoped, requiresX-Profile-Id, and hasx-silo-retry-safety: domain_identity.denyDeviceLoginisauthenticatedanddomain_identity. Both return 200{status}. A domain-identity retry is safe, so the normal 401 refresh-and-resend stays.getDeviceLoginis public; the phone still sends its bearer and profile there, which the server accepts.Failure outcomes
status)handoff_ready, re-check the owner, then launch playback.fail(...)). A 410 does not touch the tokens.fail(...)drops the control session. The TV sees the connection close and cancels its handoff (handleConnectionClosed→cancelPendingHandoff), so it does not wait for the server-side expiry.Validation
SiloTests/AuthDeviceV2Tests SiloTests/SiloControlTests SiloTests/PairingDeviceAPITests SiloTests/PairingCoordinatorTests) passed (45 tests, 0 failures).SiloTVTests/AuthDeviceV2Tests SiloTVTests/PairingDeviceAPITests) passed (28 tests, 0 failures).scripts/ci/check-no-api-v1.shpassed.SiloControlClient.swiftno longer contains a/api/v1path.testHandoffLookupApproveAndDenyUseTheV2Wirechecks paths, methods, thecodequery, the bearer,X-Profile-Idand the{"code"}body.testHandoffDecisionFailuresAreTyped: a deny answered as approved is refused, and a 410 problem is typed and leaves the tokens in place.testHandoffApprovalRefusesAChangedProfileProofBeforeDispatch: nothing is sent after the profile proof changes.testHandoffApprovesOnlyATemporaryRemotePlaybackRequest(iOS only).Risks and follow-ups
SiloControlClientdepends onServerRegistryand the singletonTokenStore, so only the wire calls and the match predicate are covered.APIv2Error.localizedDescription, so a 409 or 410 shows the server's problem detail. There is no handoff-specific copy.deviceLookupanddecideDeviceLoginstay inAPIv2Client.swiftbecause they already existed there. This PR adds no new client methods.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 14 of 50 in the Apple API v2 stack. Base:
apiv2-stack/13-pair-devices-through-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code