feat: wire media service into gateway — proxy, auth, app registration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ SPOTIZERR_URL = os.environ.get("SPOTIZERR_URL", "http://spotizerr-app:7171")
|
||||
BUDGET_URL = os.environ.get("BUDGET_BACKEND_URL", "http://localhost:3001")
|
||||
TASKS_URL = os.environ.get("TASKS_BACKEND_URL", "http://tasks-service:8098")
|
||||
BRAIN_URL = os.environ.get("BRAIN_BACKEND_URL", "http://brain-api:8200")
|
||||
MEDIA_URL = os.environ.get("MEDIA_BACKEND_URL", "http://media-api:8400")
|
||||
|
||||
# ── Service API keys (for internal service auth) ──
|
||||
INVENTORY_SERVICE_API_KEY = os.environ.get("INVENTORY_SERVICE_API_KEY", "")
|
||||
|
||||
@@ -8,7 +8,7 @@ import bcrypt
|
||||
|
||||
from config import (
|
||||
DB_PATH, TRIPS_URL, FITNESS_URL, INVENTORY_URL,
|
||||
MINIFLUX_URL, READER_URL, SHELFMARK_URL, SPOTIZERR_URL, BUDGET_URL, TASKS_URL, BRAIN_URL,
|
||||
MINIFLUX_URL, READER_URL, SHELFMARK_URL, SPOTIZERR_URL, BUDGET_URL, TASKS_URL, BRAIN_URL, MEDIA_URL,
|
||||
)
|
||||
|
||||
|
||||
@@ -140,6 +140,16 @@ def init_db():
|
||||
conn.commit()
|
||||
print("[Gateway] Added brain app")
|
||||
|
||||
# Ensure media/podcast app exists
|
||||
media = c.execute("SELECT id FROM apps WHERE id = 'media'").fetchone()
|
||||
if not media:
|
||||
c.execute("INSERT INTO apps VALUES ('media', 'Media', 'headphones', '/media', ?, 10, 1, NULL)", (MEDIA_URL,))
|
||||
conn.commit()
|
||||
print("[Gateway] Added media app")
|
||||
else:
|
||||
c.execute("UPDATE apps SET proxy_target = ? WHERE id = 'media'", (MEDIA_URL,))
|
||||
conn.commit()
|
||||
|
||||
# Seed admin user from env vars if no users exist
|
||||
import os
|
||||
user_count = c.execute("SELECT COUNT(*) FROM users").fetchone()[0]
|
||||
|
||||
@@ -325,7 +325,10 @@ class GatewayHandler(ResponseMixin, BaseHTTPRequestHandler):
|
||||
headers["X-Gateway-User-Id"] = str(user["id"])
|
||||
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
||||
elif service_id == "brain":
|
||||
# Inject user identity for the brain service
|
||||
if user:
|
||||
headers["X-Gateway-User-Id"] = str(user["id"])
|
||||
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
||||
elif service_id == "media":
|
||||
if user:
|
||||
headers["X-Gateway-User-Id"] = str(user["id"])
|
||||
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
||||
|
||||
Reference in New Issue
Block a user