fix: restore authorization filters for incident/case visibility#98
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix: restore authorization filters for incident/case visibility#98devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Use outerjoin instead of inner join in restricted_incident_filter and
restricted_case_filter so open-visibility items without participants
are not silently excluded
- Add early return for admin/owner/manager roles (default-deny approach)
- Require both restricted visibility AND matching email (and_ condition)
instead of loose or_ on email alone
- Apply model-specific filters directly to the query instead of using
intersect, which was breaking sort ordering
- Restore PermissionsDependency on GET /users/{user_id} endpoint
- Remove stray print() in apply_filter_specific_joins
Co-Authored-By: bot_apk <apk@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The authorization filters in
restricted_incident_filterandrestricted_case_filterwere using INNER JOINs onParticipant/IndividualContact, which silently dropped open-visibility incidents and cases that had no participants. Additionally, admin/owner/manager roles were not short-circuited, the restricted-visibility check was too permissive (bareor_on email instead ofand_(visibility == restricted, email == ...)), andsearch_filter_sort_paginateusedintersectwith a separate restricted query which broke sort ordering.Key changes in
src/dispatch/database/service.py:restricted_incident_filter/restricted_case_filter: early-return for admin/owner/manager; switch.join(...)→.outerjoin(...)with explicit join condition onIndividualContact.id == Participant.individual_contact_id; tighten filter toor_(visibility == open, and_(visibility == restricted, email == current_user.email))search_filter_sort_paginate: applyapply_model_specific_filtersdirectly toqueryinstead of intersecting a separatequery_restricted, preserving sort orderprint()inapply_filter_specific_joinsAlso restores
PermissionsDependency([OrganizationMemberPermission])onGET /users/{user_id}insrc/dispatch/auth/views.py.Link to Devin session: https://app.devin.ai/sessions/e75be85a9d664441a6da7100a0030d86