refactor: task api access#34
Open
praveen-bhosle wants to merge 8 commits into
Open
Conversation
Collaborator
Author
|
The PR is currently incomplete, but I wanted to get early feedback on a specific architectural piece. @amoghar29, could you please take a look at how the system auth token is being passed throughout the task and action execution flow? Let me know if you would prefer any changes in that section. |
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.
Description
celery_auth_middleware) and a dedicated token (celery_auth_token). This ensures that internal requests coming from background Celery workers originate from the trusted system user, keeping background processes secure.What’s Included
celery_auth_tokencookie andcelery_auth_middlewareto securely authenticate API calls made by asynchronous tasks, actions, and cron workers./api/v1/task/finish,/api/v1/task/update, and/api/v1/catalog/get/task_ready_to_runexclusively to the system user using the new middleware.find_itemandfind_multiple_items_by_laui. Other service methods that require deep, contextual access verification remain unchanged.Depends) across task, action, and AI route files to handle access validation upfront for these specific lookup paths.Why This Change
auth_tokenis already occupied with the initiating user's context. Thecelery_auth_tokenseparates this logic to prove that the request infrastructure itself is trusted and acting as the system user.find_itemandfind_multiple_items_by_lauiwere responsible for enforcing access rights. Because these two specific methods are invoked at incredibly high frequencies across various flows (tasks, actions, AI engines, etc.), they resulted in highly repetitive and redundant permission queries to the Ory Keto database.Acceptance Criteria
/task/finish,/task/update,/catalog/get/task_ready_to_run) successfully reject requests missing a validcelery_auth_tokencontaining system user claims.find_itemandfind_multiple_items_by_lauireliably fetch items without internal access-check overhead.How to Test
/api/v1/task/finishor/api/v1/catalog/get/task_ready_to_runvia an external client (e.g., Postman or browser) using a standard user session. Ensure it returns a401/403Unauthorized error.celery_auth_tokenand interacts with the protected endpoints.find_itemorfind_multiple_items_by_laui. Verify that:Tech Guide
celery_auth_middleware: Intercepts HTTP requests routed to background-worker-facing endpoints. It extracts thecelery_auth_tokenfrom incoming cookies and validates that the token claims strictly match the System User'slaui.Depends(...)specifically for flows hittingfind_itemandfind_multiple_items_by_laui. These two service methods now operate under the assumption that data access has already been verified, reducing repeated lookups for high-velocity internal calls. Deep access checks inside other service layer methods remain untouched.User Guide
Screenshots / Videos
N/A
Checklist