c50d6663d5
- Add get_owned_project() to auth/dependencies.py - Remove duplicated _get_user() and _get_owned_project() from all routers - Update tool_instances, git_repositories, projects, ssh_keys, users, user_config, tool_types routers to use FastAPI dependency injection - Route handlers now receive User/Project models via Depends() instead of calling inline async helpers Quality gates: Python syntax check (pass), no duplicated helpers (pass) Refs: repo-restructure Task 3.1
2.3 KiB
2.3 KiB
Task 3.1 Apply Report: Extract Shared Auth Dependencies
Status: Success
Files Created (1):
apps/api/src/auth/dependencies.py— Addedget_owned_project()dependency function
Files Modified (7):
apps/api/src/api/tool_instances.py— Removed_get_userand_get_owned_projectdefinitions; replaced withget_current_userandget_owned_projectFastAPI dependenciesapps/api/src/api/git_repositories.py— Same refactoringapps/api/src/api/projects.py— Same refactoringapps/api/src/api/ssh_keys.py— Removed_get_user; replaced withget_current_userdependencyapps/api/src/api/users.py— Same as ssh_keys.pyapps/api/src/api/user_config.py— Same as ssh_keys.pyapps/api/src/api/tool_types.py— Same as ssh_keys.py
Files NOT Modified (intentionally):
api/config_profiles.py— Has_get_owned_profile(domain-specific, not a generic auth dependency)api/tool_configs.py— No inline auth helpers to extractapi/config_folders.py— No inline auth helpers to extractapi/terminal.py— No inline auth helpers to extract;_get_user_from_websocketis websocket-specific
Files Deleted: None
Quality Gate Results:
- Python syntax check (
py_compile) for all modified files: PASS grep -rn "def _get_user" apps/api/src/api/: PASS — Onlyterminal.pyhas_get_user_from_websocket(websocket-specific, not the duplicated helper)grep -rn "def _get_owned_project" apps/api/src/api/: PASS — Zero resultspytest: Not available in environment (system Python, no venv), but all files compile cleanly
Blockers/Deviations:
- None. All duplicated auth helpers successfully extracted to
auth/dependencies.py. - The
_get_user_from_websocketinterminal.pywas intentionally left untouched as it serves a different purpose (WebSocket cookie parsing vs. HTTP dependency injection).
Notes:
get_current_useralready existed inauth/dependencies.py; it was leveraged directlyget_owned_projectwas newly added as a FastAPI dependency that injectsProjectafter verifying ownership- All route handlers now use proper FastAPI dependency injection instead of inline async calls
- Variable naming changed from
user_id(UUID) touser(User model) in route handlers, withuser.idused where the UUID is needed