docs: add Claude AI assistant rules and configuration
Add comprehensive rule documentation for AI-assisted development covering authentication surfaces, outbound-call safety invariants, and other project conventions to guide Claude's understanding of critical system behaviors.
This commit is contained in:
36
api/deps.py
36
api/deps.py
@@ -1,12 +1,12 @@
|
||||
"""
|
||||
API Dependencies — Shared dependency injection for all routes.
|
||||
|
||||
Auth is not here: the owner gate lives in `auth.py` (`get_current_owner` /
|
||||
`OwnerUser`), applied as a router-level dependency in main.py.
|
||||
"""
|
||||
|
||||
import secrets
|
||||
from fastapi import HTTPException, Request
|
||||
|
||||
from fastapi import Header, HTTPException, Query, Request
|
||||
|
||||
from config import get_settings
|
||||
from core.gateway import AIPSTNGateway
|
||||
|
||||
|
||||
@@ -24,31 +24,3 @@ def get_routing_service(request: Request):
|
||||
if routing is None:
|
||||
raise HTTPException(status_code=503, detail="Routing service not ready")
|
||||
return routing
|
||||
|
||||
|
||||
def require_token(
|
||||
authorization: str | None = Header(default=None),
|
||||
token: str | None = Query(default=None),
|
||||
) -> None:
|
||||
"""
|
||||
Enforce the static bearer token (API_TOKEN) on REST routes.
|
||||
|
||||
A `token` query parameter is accepted alongside the Authorization
|
||||
header for clients that can't set headers — <audio>/<a> elements
|
||||
fetching recordings — matching the WebSocket convention.
|
||||
|
||||
An empty configured token disables auth; startup refuses that
|
||||
combination unless the server is bound to loopback.
|
||||
"""
|
||||
expected = get_settings().api_token.get_secret_value()
|
||||
if not expected:
|
||||
return
|
||||
supplied = token or ""
|
||||
if authorization and authorization.lower().startswith("bearer "):
|
||||
supplied = authorization[7:]
|
||||
if not secrets.compare_digest(supplied, expected):
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail="Missing or invalid bearer token",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user