potpie
potpie copied to clipboard
Add API Key Authentication to Search API
Description
The current search API in app/modules/search/search_router.py only uses bearer token authentication through AuthService.check_auth. We need to add API key authentication support to make it consistent with other API endpoints in app/api/router.py that use get_api_key_user dependency.
Current Implementation
Currently, the search endpoint is defined as:
@router.post("/search", response_model=SearchResponse)
async def search_codebase(
search_request: SearchRequest,
db: Session = Depends(get_db),
user=Depends(AuthService.check_auth),
):
# ...
Expected Implementation
The new endpoint should:
- Accept an API key through the X-API-Key header
- Reuse the get_api_key_user dependency from app/api/router.py
- Keep the same request/response models
Suggested Implementation Path
- Import get_api_key_user from app/api/router.py
- Update the search endpoint to use this dependency
- Add appropriate error handling for authentication failures