Skip to content

refactor(auth): centralize task ownership verification - #2466

Open
Devexhhh wants to merge 1 commit into
utksh1:mainfrom
Devexhhh:refactor/reusable-owner-dependency
Open

refactor(auth): centralize task ownership verification#2466
Devexhhh wants to merge 1 commit into
utksh1:mainfrom
Devexhhh:refactor/reusable-owner-dependency

Conversation

@Devexhhh

@Devexhhh Devexhhh commented Aug 5, 2026

Copy link
Copy Markdown

Description

This PR centralizes task ownership verification by moving require_owned_task from routes.py to auth.py, making it reusable across the application. It also refactors multiple task-related endpoints to use the shared helper instead of duplicating ownership validation logic.

The following endpoints were updated to use the shared helper:

  • CSV report download
  • HTML report download
  • PDF report download
  • SARIF report download
  • Task diff endpoint

This reduces duplicated authorization logic while preserving the existing ownership checks and improving maintainability.

Related Issues

Closes #1197

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Note: If this issue was intended as a pure refactor with no API behavior changes, change this to Bug fix instead. Based on the current diff, the intent appears to be a non-breaking refactor, so use Bug fix if no behavior changed.

How Has This Been Tested?

  • Verified that the backend starts successfully after the refactor.
  • Performed a manual review to ensure the refactored endpoints use the shared require_owned_task helper.
  • Ran the project's test suite. Existing unrelated test collection issues (missing optional plugins and duplicate test module names) prevented the full suite from completing, but no errors were introduced by this refactor during module import after fixing the required imports.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good refactor. Centralizes task ownership verification and reduces duplication across download/diff endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Create a reusable ownership verification dependency for protected resources

2 participants