fix(private-api): device routes only act on the signed-in account - #102
Conversation
register-device and detail-device now require the body username to be the account the code belongs to (case-insensitive, like the notifications feed), and answer 403 otherwise without calling upstream. Code validation and the upstream call get test seams, as the curation desk routes have.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
PR Summary by QodoRestrict device routes to the signed-in account
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Device changes lack parity records
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughDevice routes now verify that the requested username matches the account validated by the device code. Accepted requests use replaceable validation and upstream delegates. Tests cover registration, detail retrieval, invalid codes, mismatches, missing usernames, and case-insensitive matches. ChangesDevice authorization
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant RegisterDevice
participant DeviceValidateCode
participant IsOwnDeviceRequest
participant DeviceUpstream
RegisterDevice->>DeviceValidateCode: Validate device code
DeviceValidateCode-->>RegisterDevice: Return account or null
RegisterDevice->>IsOwnDeviceRequest: Compare requested username
alt Account matches
IsOwnDeviceRequest-->>RegisterDevice: Return true
RegisterDevice->>DeviceUpstream: Forward device request
DeviceUpstream-->>RegisterDevice: Return response
else Invalid code or mismatch
IsOwnDeviceRequest-->>RegisterDevice: Return false
end
Merge Risk: ⚪ Minimal · up to The device routes now reject missing or mismatched usernames before forwarding requests, with tests covering accepted and rejected authorization outcomes. No unresolved merge-readiness risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. A rabbit checks the code at dawn Comment |
/private-api/register-deviceand/private-api/detail-devicenow require the bodyusernameto be the account the code belongs to. The comparison is case-insensitive, as inResolveNotificationsTarget. Anything else gets 403 without an upstream call.The web app and the mobile app already send the signed-in account's own username with its own code, so nothing legitimate changes.
To test the handlers without chain RPC or network, code validation and the upstream call get test seams (
DeviceValidateCode,DeviceUpstream), following the curation desk routes.Test plan
DeviceAuthorizationTests: the rule itself (own account in any case accepted; other, near-miss, missing and unvalidated refused).DeviceHandlerTests: both handlers forward the own account (endpoint and payload checked), and answer 403 for another or missing username and 401 for an invalid code, with no upstream call.dotnet test: 523 passed.Summary by CodeRabbit