Conversation
- Add organizationId field to chatRequestSchema - Create validateOrganizationAccess function to check if an account can operate on behalf of an organization (either IS the org or is a member) - Validate organizationId in validateChatRequest and use it to override orgId when user is authorized - Return 403 error when user is not a member of the specified org - Add comprehensive tests for all scenarios Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-apichat-accept-organizationid-with-auth-validation feat(api): accept organizationId in chat requests with auth validation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughA new organization access validation module is introduced to verify that accounts have access to specified organizations. This validation is integrated into chat request handling via an optional Changes
Sequence DiagramsequenceDiagram
participant Client
participant ValidateChatRequest as Chat Request Validator
participant ValidateOrgAccess as Organization Access Validator
participant Database as Membership DB
Client->>ValidateChatRequest: POST chat request (with organizationId)
activate ValidateChatRequest
ValidateChatRequest->>ValidateOrgAccess: validateOrganizationAccess(accountId, organizationId)
activate ValidateOrgAccess
alt Direct Ownership
ValidateOrgAccess->>ValidateOrgAccess: Check if accountId equals organizationId
ValidateOrgAccess-->>ValidateChatRequest: return true
else Membership Check
ValidateOrgAccess->>Database: getAccountOrganizations(accountId, organizationId)
activate Database
Database-->>ValidateOrgAccess: return memberships array
deactivate Database
ValidateOrgAccess->>ValidateOrgAccess: Check if non-empty
ValidateOrgAccess-->>ValidateChatRequest: return boolean
end
deactivate ValidateOrgAccess
alt Access Granted
ValidateChatRequest->>ValidateChatRequest: Set orgId to organizationId
ValidateChatRequest-->>Client: Continue chat validation
else Access Denied
ValidateChatRequest-->>Client: 403 Forbidden
end
deactivate ValidateChatRequest
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
✏️ Tip: You can disable this entire section by setting 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 |
Merge test branch changes to main
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.