Skip to content

Commit df9ccf8

Browse files
committed
refactor(auth): migrate core API routes to unified auth
- POST /api/repos/{id}/index - POST /api/search - POST /api/explain - GET /api/repos/{id}/dependencies - POST /api/repos/{id}/impact - GET /api/repos/{id}/insights - GET /api/repos/{id}/style-analysis All now use require_auth + AuthContext Part of #12
1 parent 290d6db commit df9ccf8

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

backend/main.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,9 @@ async def progress_callback(files_processed: int, functions_indexed: int, total_
262262
async def index_repository(
263263
repo_id: str,
264264
incremental: bool = True,
265-
api_key: str = Header(None, alias="Authorization")
265+
auth: AuthContext = Depends(require_auth)
266266
):
267267
"""Trigger indexing for a repository - automatically uses incremental if possible"""
268-
verify_api_key(api_key)
269268

270269
import time
271270
import git
@@ -322,10 +321,9 @@ async def index_repository(
322321
@app.post("/api/search")
323322
async def search_code(
324323
request: SearchRequest,
325-
api_key: str = Header(None, alias="Authorization")
324+
auth: AuthContext = Depends(require_auth)
326325
):
327326
"""Search code semantically with caching and validation"""
328-
verify_api_key(api_key)
329327

330328
# Validate search query
331329
valid_query, query_error = InputValidator.validate_search_query(request.query)
@@ -368,10 +366,9 @@ async def search_code(
368366
@app.post("/api/explain")
369367
async def explain_code(
370368
request: ExplainRequest,
371-
api_key: str = Header(None, alias="Authorization")
369+
auth: AuthContext = Depends(require_auth)
372370
):
373371
"""Generate code explanation"""
374-
verify_api_key(api_key)
375372

376373
try:
377374
repo = repo_manager.get_repo(request.repo_id)
@@ -400,10 +397,9 @@ class ImpactRequest(BaseModel):
400397
@app.get("/api/repos/{repo_id}/dependencies")
401398
async def get_dependency_graph(
402399
repo_id: str,
403-
api_key: str = Header(None, alias="Authorization")
400+
auth: AuthContext = Depends(require_auth)
404401
):
405402
"""Get dependency graph for repository with Supabase caching"""
406-
verify_api_key(api_key)
407403

408404
try:
409405
repo = repo_manager.get_repo(repo_id)
@@ -434,10 +430,9 @@ async def get_dependency_graph(
434430
async def analyze_impact(
435431
repo_id: str,
436432
request: ImpactRequest,
437-
api_key: str = Header(None, alias="Authorization")
433+
auth: AuthContext = Depends(require_auth)
438434
):
439435
"""Analyze impact of changing a file with validation and caching"""
440-
verify_api_key(api_key)
441436

442437
try:
443438
repo = repo_manager.get_repo(repo_id)
@@ -474,10 +469,9 @@ async def analyze_impact(
474469
@app.get("/api/repos/{repo_id}/insights")
475470
async def get_repository_insights(
476471
repo_id: str,
477-
api_key: str = Header(None, alias="Authorization")
472+
auth: AuthContext = Depends(require_auth)
478473
):
479474
"""Get comprehensive insights about repository with Supabase caching"""
480-
verify_api_key(api_key)
481475

482476
try:
483477
repo = repo_manager.get_repo(repo_id)
@@ -517,10 +511,9 @@ class ImpactRequest(BaseModel):
517511
@app.get("/api/repos/{repo_id}/style-analysis")
518512
async def get_style_analysis(
519513
repo_id: str,
520-
api_key: str = Header(None, alias="Authorization")
514+
auth: AuthContext = Depends(require_auth)
521515
):
522516
"""Analyze code style and team patterns with Supabase caching"""
523-
verify_api_key(api_key)
524517

525518
try:
526519
repo = repo_manager.get_repo(repo_id)

0 commit comments

Comments
 (0)