mirror of
https://github.com/hanzoai/mpc.git
synced 2026-10-30 19:45:28 +00:00
* ci: add id-token: write to caller permissions
Required for hanzoai/.github/.github/workflows/docker-build.yml@main —
without it the workflow_call dies as startup_failure with no jobs
dispatched. Caller permissions are a CEILING.
* go.mod: bump go directive to 1.26.3 (security advisory)
* deps: luxfi/crypto v1.19.0
* deps: luxfi/crypto v1.19.0; refresh stale checksums
* feat(landing): brand-neutral landing/dashboard with per-Host branding
The MPC binary now resolves its visible brand at request time from the
HTTP Host header, so a single image serves mpc.hanzo.ai as "Hanzo MPC",
mpc.lux.network as "Lux MPC", mpc.zoo.network as "Zoo MPC", and every
other host as a generic brand-free "MPC".
What changed:
- New pkg/landing/ subpackage with:
- brand.go: Brand{} struct + FromHost(host) helper + brandTable map
keyed on registered domain (hanzo.ai/lux.network/zoo.network).
Unknown hosts -> zero Brand -> generic page (no brand prefix, no
"Sign In with X ID" suffix, no IAM redirect).
- templates.go: html/template-backed landing/dashboard/auth-callback
HTML. Every visible brand-specific string flows through
{{.Brand.TitlePrefix}}, {{.Brand.SignInLabel}}, {{.Brand.IAMURL}},
{{.Brand.DocsURL}}, {{.Brand.SiteURL}}, {{.Brand.GitHubURL}}.
- landing.go: http.Handler that intercepts GET /, /dashboard,
/auth/callback and delegates everything else to the next handler.
Templates parsed once via sync.Once; per-request execution is
bytes.Buffer-based.
- brand_test.go: per-Host title/body assertions for hanzo.ai (Hanzo),
lux.network (Lux), zoo.network (Zoo), and an unknown host
(generic). Includes a delegation test that ensures unknown paths
fall through to next.
- cmd/mpcd/main.go: wrap apiServer.Handler() in landing.Handler() so
the marketing/dashboard pages render brand-aware while the canonical
/v1/* API surface (signing, keygen, wallets) is unchanged. Same Base
mount, same SQLite, same MPC backend wire protocol.
- cmd/mpcd/main.go: add the missing HasSigningQuorum(threshold) shim on
ConsensusPeerRegistry so the build keeps up with the recent luxfi/mpc
PeerRegistry interface addition (mirrors the consul registry).
No behavioral change to keygen/signing/reshare. /health, /healthz,
/keys, /backup, /keygen on the internal API port (9800) are untouched.
Verified locally:
$ go test ./pkg/landing/... -v
=== RUN TestFromHost --- PASS
=== RUN TestBrandHelpers --- PASS
=== RUN TestHandlerPerHostBranding --- PASS
=== RUN TestHandlerDelegatesUnknownPaths --- PASS
ok github.com/hanzoai/mpc/pkg/landing
To onboard a new white-label deployment, add one row to brandTable in
pkg/landing/brand.go and point its DNS at the cluster — no code change
beyond that table.
* docker: self-sufficient build (clone luxfi/mpc inside builder)
Restores compatibility with the canonical reusable workflow
`hanzoai/.github/.github/workflows/docker-build.yml@main`, which does
a single `actions/checkout@v4` at the workspace root with
`context: .`. The previous Dockerfile assumed the historical CI did
two checkouts and built from the parent dir.
The replace `github.com/luxfi/mpc => ../../lux/mpc` directive is now
satisfied inside the build by `git clone --depth=1 --branch=...
https://github.com/luxfi/mpc.git` into `/build/lux/mpc`, parallel to
`/build/hanzo/mpc` (the COPY of the build context).
Pin: `LUXFI_MPC_REF=v1.14.4` (latest released tag at time of write,
known to satisfy the PeerRegistry.HasSigningQuorum interface). Override
via `--build-arg LUXFI_MPC_REF=<tag>` when reproducibility matters.
72 lines
2.2 KiB
Go
72 lines
2.2 KiB
Go
package landing
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
"net/http"
|
|
"sync"
|
|
)
|
|
|
|
// Handler returns an http.Handler that serves three brand-neutral pages
|
|
// driven by the Host header:
|
|
//
|
|
// GET / landing page (marketing surface)
|
|
// GET /dashboard post-OAuth dashboard
|
|
// GET /auth/callback OAuth code-exchange page
|
|
//
|
|
// All other paths are delegated to next. The brand for each request is
|
|
// resolved from r.Host via FromHost so the same binary serves every
|
|
// white-label tenant without rebuilds.
|
|
func Handler(next http.Handler) http.Handler {
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("GET /{$}", serveLanding)
|
|
mux.HandleFunc("GET /dashboard", serveDashboard)
|
|
mux.HandleFunc("GET /auth/callback", serveAuthCallback)
|
|
if next != nil {
|
|
mux.Handle("/", next)
|
|
}
|
|
return mux
|
|
}
|
|
|
|
// pageData is the template payload. We keep one template per page (parsed
|
|
// once) and execute it per request with the resolved Brand. tpls is a
|
|
// sync.Once-guarded pre-parsed cache so we never re-parse on the hot path.
|
|
type pageData struct {
|
|
Brand Brand
|
|
}
|
|
|
|
var (
|
|
tpls map[string]*template.Template
|
|
tplsOnce sync.Once
|
|
)
|
|
|
|
func loadTemplates() {
|
|
tpls = map[string]*template.Template{
|
|
"landing": template.Must(template.New("landing").Parse(landingTemplate)),
|
|
"dashboard": template.Must(template.New("dashboard").Parse(dashboardTemplate)),
|
|
"authCallback": template.Must(template.New("authCallback").Parse(authCallbackTemplate)),
|
|
}
|
|
}
|
|
|
|
func render(w http.ResponseWriter, r *http.Request, name string) {
|
|
tplsOnce.Do(loadTemplates)
|
|
t, ok := tpls[name]
|
|
if !ok {
|
|
http.Error(w, "template not found", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
var buf bytes.Buffer
|
|
if err := t.Execute(&buf, pageData{Brand: FromHost(r.Host)}); err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
w.Header().Set("Cache-Control", "no-cache")
|
|
w.WriteHeader(http.StatusOK)
|
|
_, _ = w.Write(buf.Bytes())
|
|
}
|
|
|
|
func serveLanding(w http.ResponseWriter, r *http.Request) { render(w, r, "landing") }
|
|
func serveDashboard(w http.ResponseWriter, r *http.Request) { render(w, r, "dashboard") }
|
|
func serveAuthCallback(w http.ResponseWriter, r *http.Request) { render(w, r, "authCallback") }
|