microsoft / microsoft/AzureTRE
Dependencies are duplicated which could cause auth checks to run twice within the API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 235
- Forks
- 192
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 13
Description
Describe the bug
Dependencies are duplicated which would cause auth checks to run twice within the API
e.g get_current_tre_user_or_tre_admin in api_app/api/routes/shared_services.py
shared_services_router = APIRouter(dependencies=[Depends(**get_current_tre_user_or_tre_admin**)])
@shared_services_router.get("/shared-services", response_model=SharedServicesInList, name=strings.API_GET_ALL_SHARED_SERVICES, dependencies=[Depends(**get_current_tre_user_or_tre_admin**)])
If you attach the same auth dependency both at the router level (via APIRouter(dependencies=[Depends(auth)])) >and again on the endpoint (either in dependencies=[Depends(auth)] or as a parameter user = Depends(auth)), >FastAPI will execute it twice because each Depends(...) occurrence is evaluated independently; router-level >dependencies are simply added to the route’s dependency list. [fastapi.tiangolo.com]
Azure TRE release version (e.g. v0.14.0 or main):
main
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in api_app/api/routes/shared_services.py and inspect the shared_services_router declaration alongside its endpoint dependencies. Check the surrounding API routes for the same duplication pattern, then verify that each request performs the authentication check once and that the affected routes retain their required protection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100