Phase 4: cloud backend — licensing, heartbeat, site management
- New cloud_backend/ FastAPI service on port 8001 (SQLite for dev, swappable to PostgreSQL) - Endpoints: sysadmin auth (JWT), site registration, lock/unlock, heartbeat (X-Site-ID + X-Site-Key headers) - Default sysadmin seeded on first startup from ADMIN_USERNAME/ADMIN_PASSWORD env vars - cloud_backend added to docker-compose.yml with persistent data volume at ./data/cloud/ - local_backend cloud_sync.py updated to use correct /api/heartbeat/ endpoint with header auth - local_backend config.py: added SITE_KEY setting - Smoke tested: login, register site, heartbeat, lock, unlock, list all pass
This commit is contained in:
0
cloud_backend/models/__init__.py
Normal file
0
cloud_backend/models/__init__.py
Normal file
11
cloud_backend/models/admin.py
Normal file
11
cloud_backend/models/admin.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from database import Base
|
||||
|
||||
|
||||
class Admin(Base):
|
||||
__tablename__ = "admins"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String, unique=True, nullable=False)
|
||||
password_hash = Column(String, nullable=False)
|
||||
role = Column(String, default="sysadmin")
|
||||
21
cloud_backend/models/site.py
Normal file
21
cloud_backend/models/site.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
from database import Base
|
||||
|
||||
|
||||
class Site(Base):
|
||||
__tablename__ = "sites"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
site_id = Column(String, unique=True, nullable=False, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
owner_name = Column(String, nullable=False)
|
||||
contact_email = Column(String, nullable=False)
|
||||
secret_key_hash = Column(String, nullable=False)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_locked = Column(Boolean, default=False)
|
||||
lock_reason = Column(String, nullable=True)
|
||||
license_expires_at = Column(DateTime(timezone=True), nullable=False)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
last_seen_at = Column(DateTime(timezone=True), nullable=True)
|
||||
last_seen_ip = Column(String, nullable=True)
|
||||
Reference in New Issue
Block a user