dependencies.py
python
sha256:f99af7b1a7f36c4d537d1c630d4b71fc39222b1255f82e930929e2fc89015e11
fix: relax browse_repo perf budget to 500ms — 200ms was too…
Sonnet 4.6
100 days ago
| 1 | """FastAPI authentication dependencies — MSign per-request signing. |
| 2 | |
| 3 | All authenticated endpoints use ``Depends(require_valid_token)`` or |
| 4 | ``Depends(optional_token)`` — the same names as before, now backed by |
| 5 | MSign Ed25519 per-request signing. |
| 6 | """ |
| 7 | |
| 8 | import logging |
| 9 | |
| 10 | from fastapi import Header, HTTPException, status |
| 11 | |
| 12 | from musehub.auth.request_signing import ( |
| 13 | MSignContext, |
| 14 | optional_signed_request, |
| 15 | require_scope, |
| 16 | require_signed_request, |
| 17 | ) |
| 18 | |
| 19 | logger = logging.getLogger(__name__) |
| 20 | |
| 21 | # Re-export under the names the rest of the codebase expects |
| 22 | TokenClaims = MSignContext |
| 23 | require_valid_token = require_signed_request |
| 24 | optional_token = optional_signed_request |
| 25 | |
| 26 | async def require_device_id( |
| 27 | x_device_id: str | None = Header(None, alias="X-Device-ID"), |
| 28 | ) -> str: |
| 29 | """FastAPI dependency for asset endpoints: require a non-empty X-Device-ID header.""" |
| 30 | if not x_device_id or not x_device_id.strip(): |
| 31 | logger.warning("Asset request without X-Device-ID") |
| 32 | raise HTTPException( |
| 33 | status_code=status.HTTP_400_BAD_REQUEST, |
| 34 | detail="X-Device-ID header required", |
| 35 | ) |
| 36 | return x_device_id.strip() |
File History
2 commits
sha256:f99af7b1a7f36c4d537d1c630d4b71fc39222b1255f82e930929e2fc89015e11
fix: relax browse_repo perf budget to 500ms — 200ms was too…
Sonnet 4.6
100 days ago
sha256:763eb2cb8675073b84c19345b27586d2ed939a9aee97c5479b69f502f1a70eff
fix(tests): update test suite to match current implementation
Sonnet 4.6
patch
122 days ago