Files
claudeandClaude Opus 5.5 7d6eec8963 Harmony on eom.dev: Supabase + Harmony on Kubernetes, Dex sign-in, Catppuccin, LiveKit
Kubernetes port of Harmony 1.9.6's self-host compose stack (Supabase Postgres,
GoTrue, PostgREST, Realtime, storage-api, imgproxy, Kong; Harmony web,
federation server/worker, Redis, media cache, Caddy router; LiveKit) at
harmony.eom.dev, api.harmony.eom.dev and voice.harmony.eom.dev.

- Dex is the only sign-in (GoTrue custom OIDC provider custom:dex); e-mail
  login off; listed addresses become instance admins.
- Upstream bootstrap.sh runs unchanged in a Job through a docker shim.
- Catppuccin Mocha/Latte stylesheet injected into the stock web image.
- Secrets generated once and kept in Secret/harmony.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 17:31:50 -05:00

47 lines
1.7 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: MIT-0
"""Derived keys for Harmony, the way self-host/configure.sh makes them.
Reads JWT_SECRET from the environment and prints JSON:
anon_key, service_role_key HS256 JWTs (role anon / service_role, iss supabase,
valid 10 years), signed with JWT_SECRET
vapid_public_key P-256 public point, uncompressed, base64url (87 chars)
vapid_private_key P-256 private scalar, base64url (43 chars)
Only the Python standard library and `cryptography` are needed.
"""
import base64
import hashlib
import hmac
import json
import os
import time
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
def b64url(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
def sign(role: str, secret: str) -> str:
now = int(time.time())
header = b64url(json.dumps({"alg": "HS256", "typ": "JWT"}, separators=(",", ":")).encode())
payload = b64url(json.dumps({"role": role, "iss": "supabase", "iat": now, "exp": now + 315360000},
separators=(",", ":")).encode())
body = f"{header}.{payload}"
sig = hmac.new(secret.encode(), body.encode(), hashlib.sha256).digest()
return f"{body}.{b64url(sig)}"
secret = os.environ["JWT_SECRET"]
key = ec.generate_private_key(ec.SECP256R1())
priv = key.private_numbers().private_value.to_bytes(32, "big")
pub = key.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint)
print(json.dumps({
"anon_key": sign("anon", secret),
"service_role_key": sign("service_role", secret),
"vapid_public_key": b64url(pub),
"vapid_private_key": b64url(priv),
}))