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:
@@ -67,6 +67,7 @@ services:
|
|||||||
- TASKS_SERVICE_API_KEY=${TASKS_SERVICE_API_KEY}
|
- TASKS_SERVICE_API_KEY=${TASKS_SERVICE_API_KEY}
|
||||||
- BRAIN_BACKEND_URL=http://brain-api:8200
|
- BRAIN_BACKEND_URL=http://brain-api:8200
|
||||||
- READER_BACKEND_URL=http://reader-api:8300
|
- READER_BACKEND_URL=http://reader-api:8300
|
||||||
|
- MEDIA_BACKEND_URL=http://media-api:8400
|
||||||
- QBITTORRENT_HOST=${QBITTORRENT_HOST:-192.168.1.42}
|
- QBITTORRENT_HOST=${QBITTORRENT_HOST:-192.168.1.42}
|
||||||
- QBITTORRENT_PORT=${QBITTORRENT_PORT:-8080}
|
- QBITTORRENT_PORT=${QBITTORRENT_PORT:-8080}
|
||||||
- QBITTORRENT_USERNAME=${QBITTORRENT_USERNAME:-admin}
|
- QBITTORRENT_USERNAME=${QBITTORRENT_USERNAME:-admin}
|
||||||
|
|||||||
@@ -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")
|
BUDGET_URL = os.environ.get("BUDGET_BACKEND_URL", "http://localhost:3001")
|
||||||
TASKS_URL = os.environ.get("TASKS_BACKEND_URL", "http://tasks-service:8098")
|
TASKS_URL = os.environ.get("TASKS_BACKEND_URL", "http://tasks-service:8098")
|
||||||
BRAIN_URL = os.environ.get("BRAIN_BACKEND_URL", "http://brain-api:8200")
|
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) ──
|
# ── Service API keys (for internal service auth) ──
|
||||||
INVENTORY_SERVICE_API_KEY = os.environ.get("INVENTORY_SERVICE_API_KEY", "")
|
INVENTORY_SERVICE_API_KEY = os.environ.get("INVENTORY_SERVICE_API_KEY", "")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import bcrypt
|
|||||||
|
|
||||||
from config import (
|
from config import (
|
||||||
DB_PATH, TRIPS_URL, FITNESS_URL, INVENTORY_URL,
|
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()
|
conn.commit()
|
||||||
print("[Gateway] Added brain app")
|
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
|
# Seed admin user from env vars if no users exist
|
||||||
import os
|
import os
|
||||||
user_count = c.execute("SELECT COUNT(*) FROM users").fetchone()[0]
|
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-Id"] = str(user["id"])
|
||||||
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
||||||
elif service_id == "brain":
|
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:
|
if user:
|
||||||
headers["X-Gateway-User-Id"] = str(user["id"])
|
headers["X-Gateway-User-Id"] = str(user["id"])
|
||||||
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
headers["X-Gateway-User-Name"] = user.get("display_name", user.get("username", ""))
|
||||||
|
|||||||
Reference in New Issue
Block a user