feat: Initial Hub implementation
Complete LetsBe Hub service for license management and telemetry: - Client and Instance CRUD APIs - License key generation and validation (lb_inst_ format) - Hub API key generation (hk_ format) for telemetry auth - Instance activation endpoint - Telemetry collection with privacy-first redactor - Key rotation and suspend/reactivate functionality - Alembic migrations for PostgreSQL - Docker Compose deployment ready - Comprehensive test suite 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
5
app/dependencies/__init__.py
Normal file
5
app/dependencies/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""Hub dependencies."""
|
||||
|
||||
from app.dependencies.admin_auth import validate_admin_key
|
||||
|
||||
__all__ = ["validate_admin_key"]
|
||||
28
app/dependencies/admin_auth.py
Normal file
28
app/dependencies/admin_auth.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Admin authentication dependency."""
|
||||
|
||||
import secrets
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Header, HTTPException, status
|
||||
|
||||
from app.config import settings
|
||||
|
||||
|
||||
def validate_admin_key(
|
||||
x_admin_api_key: Annotated[str, Header(description="Admin API key")],
|
||||
) -> str:
|
||||
"""
|
||||
Validate the admin API key.
|
||||
|
||||
Uses constant-time comparison to prevent timing attacks.
|
||||
"""
|
||||
if not secrets.compare_digest(x_admin_api_key, settings.ADMIN_API_KEY):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid admin API key",
|
||||
)
|
||||
return x_admin_api_key
|
||||
|
||||
|
||||
# Type alias for dependency injection
|
||||
AdminKeyDep = Annotated[str, validate_admin_key]
|
||||
Reference in New Issue
Block a user