feat: enhance account retrieval with authentication checks#395
Conversation
…ecoupable#385) (recoupable#393) * feat: migrate chat trailing messages delete endpoint * fix: add handler-level error guard for trailing delete * refactor: reuse existing memories helpers for trailing delete * refactor: reuse shared memories helpers for trailing delete * refactor: remove trailing delete count response * fix: harden trailing delete cursor and timestamp guard * fix: align trailing delete boundary with memories schema
* Updated the account retrieval API to require authentication via `x-api-key` or `Authorization: Bearer`. * Added validation to ensure the caller has access to the requested account. * Introduced unit tests for the account handler to cover various scenarios including invalid UUIDs and authorization failures.
|
@luxapientia is attempting to deploy a commit to the Recoupable Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR reinforces authentication and authorization checks in the account retrieval flow by introducing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…piaccountsid-unauthenticated-read-of-full-account-row
API Test:
|
| # | Test Case | Expected | Actual | Result |
|---|---|---|---|---|
| 1 | No auth headers | 401 | "Exactly one of x-api-key or Authorization must be provided" |
PASS ✅ |
| 2 | Invalid UUID path param | 400 (before auth) | "id must be a valid UUID" |
PASS ✅ |
| 3 | Invalid API key | 401 | "Unauthorized" |
PASS ✅ |
| 4 | Both x-api-key AND Authorization |
401 | "Exactly one of x-api-key or Authorization must be provided" |
PASS ✅ |
| 5 | Valid API key → own account | 200 | Full account data returned | PASS ✅ |
| 6 | Valid admin API key → other account (shared org) | 200 | Account data returned | PASS ✅ |
| 7 | Valid admin API key → non-existent account | 404 | "Account not found" |
PASS ✅ |
| 8 | OPTIONS preflight | 200 | CORS headers returned correctly | PASS ✅ |
Notes
- Validation order is correct: UUID validation (400) runs before auth check (401), providing fast failure on bad input
- Auth uses
validateAuthContextwith{ accountId }which delegates tocanAccessAccount— supports self-access, shared org, and Recoup admin access - Could not test the 403 path (non-admin key accessing another account) without a personal (non-org) API key
🤖 Generated with Claude Code
x-api-keyorAuthorization: Bearer.Summary by CodeRabbit
Bug Fixes
Documentation