Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: improve access control in booking operations#25054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@volnei
Copy link
Contributor

What does this PR do?

This PR adds authorization checks to the booking reassignment endpoints in the Platform API v2 to ensure that only authorized users (booking organizers, team admins, or org admins) can reassign bookings.

Link to Devin run:https://app.devin.ai/sessions/6c99f3b7ed764eb5ac23b5c3c422c6b7
Requested by: Volnei Munhoz (volnei@cal.com) /@volnei

Changes Made

  • Added authorization validation inBookingsService.reassignBooking() method
  • Added authorization validation inBookingsService.reassignBookingToUser() method
  • Both methods now useBookingRepository.doesUserIdHaveAccessToBooking() to verify the requesting user has permission to modify the booking
  • Returns403 Forbidden when authorization fails

The authorization check verifies that the user is either:

  1. The booking organizer (userId matches booking.userId)
  2. A team admin of the team that owns the event type
  3. An org admin of the organization that owns the team

This follows the same authorization pattern used in the TRPC round-robin reassignment handler.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require adocumentation change. If N/A, write N/A here and check the checkbox.N/A - This is a security fix that doesn't change the API contract or require documentation updates.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.Note: No existing test infrastructure exists for API v2 services. Manual testing recommended.

How should this be tested?

Prerequisites

  • Two user accounts in the system (User A and User B)
  • User A should have a round-robin event type with bookings
  • User B should NOT be a team member or admin of User A's team

Test Case 1: Unauthorized Reassignment (Should Fail)

  1. Create a booking for User A's event type
  2. Attempt to reassign the booking using User B's API credentials
  3. Expected: Should receive403 Forbidden response
  4. Verify: Booking should remain assigned to original host

Test Case 2: Authorized Reassignment (Should Succeed)

  1. Create a booking for User A's event type
  2. Attempt to reassign the booking using User A's API credentials (or team admin credentials)
  3. Expected: Should receive200 OK response with reassigned booking
  4. Verify: Booking should be reassigned to new host

API Endpoints to Test

  • POST /v2/bookings/{bookingUid}/reassign (automatic reassignment)
  • POST /v2/bookings/{bookingUid}/reassign/{userId} (manual reassignment to specific user)

Important Review Points

⚠️Critical areas for review:

  1. Authorization Logic Completeness - DoesBookingRepository.doesUserIdHaveAccessToBooking() correctly handle all legitimate access scenarios? Review the implementation atpackages/features/bookings/repositories/BookingRepository.ts:194-224

  2. Breaking Changes - Are there any legitimate use cases where users should be able to reassign bookings they don't directly own that this change might break?

  3. Edge Cases - How does this handle:

    • Bookings with no associated event type (eventTypeId is null)?
    • Bookings for deleted teams?
    • API key authentication vs OAuth token authentication?
  4. Error Handling - Is403 Forbidden the appropriate status code, or should we use404 Not Found to avoid leaking information about booking existence?

  5. Testing - Since no automated tests were added (no existing test infrastructure for API v2 services), manual testing is critical before merge.

Checklist

  • I have read thecontributing guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my changes generate no new warnings

Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@keithwillcodekeithwillcode added corearea: core, team members only foundation labelsNov 10, 2025
@volneivolnei marked this pull request as ready for reviewNovember 10, 2025 19:55
@volneivolnei requested a review froma team as acode ownerNovember 10, 2025 19:55
@graphite-appgraphite-appbot requested a review froma teamNovember 10, 2025 19:55
Copy link
Contributor

@cubic-dev-aicubic-dev-aibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No issues found across 1 file

supalarry

This comment was marked as outdated.

@volneivolneienabled auto-merge (squash)November 10, 2025 20:08
@supalarrysupalarry self-requested a reviewNovember 10, 2025 20:17
…ation- Remove problematic import of BookingRepository from @calcom/features- Implement authorization check inline using checkUserHasAccessToBooking helper method- Replicates the authorization logic from BookingRepository.doesUserIdHaveAccessToBooking- Fixes runtime module resolution error in NestJS buildCo-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
@vercel
Copy link

vercelbot commentedNov 10, 2025
edited
Loading

The latest updates on your projects. Learn more aboutVercel for GitHub.

2 Skipped Deployments
ProjectDeploymentPreviewCommentsUpdated (UTC)
calIgnoredIgnoredNov 10, 2025 9:51pm
cal-euIgnoredIgnoredNov 10, 2025 9:51pm

Copy link
Contributor

@cubic-dev-aicubic-dev-aibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No issues found across 4 files

Copy link
Contributor

@cubic-dev-aicubic-dev-aibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No issues found across 1 file

@github-actions
Copy link
Contributor

github-actionsbot commentedNov 10, 2025
edited
Loading

E2E results are ready!

Copy link
Contributor

@cubic-dev-aicubic-dev-aibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No issues found across 2 files

@volneivolnei merged commitfd390f9 intomainNov 10, 2025
38 checks passed
@volneivolnei deleted the devin/1762803563-fix-booking-reassignment-authorization branchNovember 10, 2025 22:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cubic-dev-aicubic-dev-ai[bot]cubic-dev-ai[bot] left review comments

@keithwillcodekeithwillcodekeithwillcode approved these changes

@supalarrysupalarryAwaiting requested review from supalarry

Assignees

No one assigned

Labels

corearea: core, team members onlyfoundationready-for-e2esize/L

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@volnei@keithwillcode@supalarry

[8]ページ先頭

©2009-2025 Movatter.jp