feat(api-keys): T24-T27 implement API keys CRUD endpoints

- T24: POST /api/keys with encryption and limit validation
- T25: GET /api/keys with pagination and sorting
- T26: PUT /api/keys/{id} for partial updates
- T27: DELETE /api/keys/{id} with cascade
- Add ownership verification (403 for unauthorized access)
- API key encryption with AES-256 before storage
- Never expose API key value in responses
- 100% coverage on api_keys router (25 tests)

Refs: T24 T25 T26 T27
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-07 14:41:53 +02:00
parent 2e4c1bb1e5
commit abf7e7a532
7 changed files with 796 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from openrouter_monitor.config import get_settings
from openrouter_monitor.routers import api_keys
from openrouter_monitor.routers import auth
settings = get_settings()
@@ -29,6 +30,7 @@ app.add_middleware(
# Include routers
app.include_router(auth.router, prefix="/api/auth", tags=["authentication"])
app.include_router(api_keys.router, prefix="/api/keys", tags=["api-keys"])
@app.get("/")