Files
zeekayandGitHub cbd259f584 feat(landing): brand-neutral landing/dashboard with per-Host branding (#2)
* 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.
2026-05-15 14:52:23 -07:00

112 lines
3.8 KiB
Go

// Package landing serves the brand-neutral MPC marketing landing page and
// post-OAuth dashboard. Brand is resolved from the request Host header so
// the same binary serves mpc.hanzo.ai, mpc.lux.network, mpc.zoo.network,
// etc. with the right wordmark, IAM endpoint, and footer links.
//
// Resolution rules:
//
// - Strip the leading subdomain ("mpc.hanzo.ai" -> "hanzo.ai").
// - Look up the registered domain in the table below.
// - Anything not in the table resolves to the empty Brand which renders
// a generic, brand-free "MPC" surface (title, sign-in button, etc.
// all drop the brand prefix).
package landing
import "strings"
// Brand captures every visible string a deployment needs to brand the
// landing/dashboard. The empty Brand renders an entirely brand-neutral
// page (no wordmark prefix, no brand-suffixed sign-in button).
type Brand struct {
// Name is the wordmark, e.g. "Hanzo". Empty means no brand prefix —
// the page title becomes "MPC — ..." and the sign-in button becomes
// "Sign In" (no "with X ID" suffix).
Name string
// IAMURL is the OAuth issuer that backs the sign-in button, e.g.
// "https://hanzo.id". Empty disables in-page login (the button is
// hidden / linked to /health).
IAMURL string
// ClientID is the OAuth client_id registered at IAMURL for this
// deployment. Empty for unbranded.
ClientID string
// SiteURL is the marketing homepage, e.g. "https://hanzo.ai".
SiteURL string
// DocsURL is where "Docs" / "Read the Docs" link to.
DocsURL string
// GitHubURL is the public source link in the footer / nav.
GitHubURL string
}
// HasBrand reports whether the deployment is associated with a known
// org. Used to gate the "Sign In with X ID" button vs a plain "Sign In".
func (b Brand) HasBrand() bool { return b.Name != "" }
// TitlePrefix returns "Hanzo " for branded deployments and "" for the
// unbranded default, so callers can write "{{.TitlePrefix}}MPC — ..."
// and get either "Hanzo MPC — ..." or "MPC — ...".
func (b Brand) TitlePrefix() string {
if b.Name == "" {
return ""
}
return b.Name + " "
}
// SignInLabel returns either "Sign In with Hanzo ID" (branded) or plain
// "Sign In" (unbranded).
func (b Brand) SignInLabel() string {
if b.Name == "" {
return "Sign In"
}
return "Sign In with " + b.Name + " ID"
}
// brandTable is the per-Host brand registry. Keys are the registered
// domain (no `mpc.` subdomain, no port). One entry per supported brand —
// add a row here to onboard a new white-label deployment.
var brandTable = map[string]Brand{
"hanzo.ai": {
Name: "Hanzo",
IAMURL: "https://hanzo.id",
ClientID: "hanzo-mpc-client",
SiteURL: "https://hanzo.ai",
DocsURL: "https://docs.hanzo.ai",
GitHubURL: "https://github.com/hanzoai/mpc",
},
"lux.network": {
Name: "Lux",
IAMURL: "https://id.lux.network",
ClientID: "lux-mpc-client",
SiteURL: "https://lux.network",
DocsURL: "https://docs.lux.network/mpc",
GitHubURL: "https://github.com/luxfi/mpc",
},
"zoo.network": {
Name: "Zoo",
IAMURL: "https://zoo.id",
ClientID: "zoo-mpc-client",
SiteURL: "https://zoo.ngo",
DocsURL: "https://docs.zoo.ngo",
GitHubURL: "https://github.com/zooai/mpc",
},
}
// FromHost resolves a Brand from an HTTP Host header. Strips port and
// the leading "mpc." subdomain, then looks up the remaining registered
// domain in brandTable. Unknown hosts resolve to the zero Brand which
// renders a generic, brand-free page.
func FromHost(host string) Brand {
// Strip port if present (":443", ":8080", etc.).
if i := strings.IndexByte(host, ':'); i >= 0 {
host = host[:i]
}
host = strings.ToLower(strings.TrimSpace(host))
// Strip leading "mpc." or any other single-label subdomain that
// fronts the deployment.
if strings.HasPrefix(host, "mpc.") {
host = host[len("mpc."):]
}
return brandTable[host]
}