mirror of
https://github.com/hanzoai/id.git
synced 2026-10-16 18:38:15 +00:00
Replaces the Cloudflare Worker (hanzo.id-worker) and the Next.js portal
with a pnpm monorepo following the a-monorepo/id pattern.
Layout:
apps/web/ Vite + React 19 SPA, embeds @hanzo/gui shell
k8s/ Deployment(2) + Service + Ingress (4 hosts, 4 TLS)
pkgs/shared/ @hanzo/id-shared — TenantConfig, resolveTenant,
loadBrand (browser + node)
pkgs/auth/ @hanzo/id-auth — AuthClient (wraps @hanzo/iam REST)
+ LoginForm/SignupForm/ForgotForm/OTPForm
pkgs/idv/ @hanzo/id-idv — pluggable IDV (stub, persona,
onfido, veriff) behind one
IDVProvider interface
legacy-nextjs/ Frozen — Next.js predecessor. Delete after v0.1.0 ships.
Dockerfile Two-stage: pnpm build → hanzoai/static:0.4.1 serves /spa
README.md
LLM.md Architecture, dev, deploy, cutover plan
Tenant resolution: hostname → TenantConfig (orgId, iamUrl, clientId,
appName, publicOrigin, brandPackage). Built-in defaults for
hanzo.id/lux.id/zoo.id/pars.id; runtime override via
IAM_TENANT_CONFIG_JSON env (served as /config.json at pod startup).
Brand resolution: each per-org brand pkg (@hanzo/brand, @luxfi/brand,
@zooai/brand, @parsdao/brand) ships brand.json. The Vite plugin
brandJsonPlugin emits /brand/<pkg>/brand.json verbatim; the browser
fetches the right one based on the resolved tenant. No bundle bloat.
IDV: stub (default for dev), persona, onfido, veriff. Each adapter
implements `IDVProvider` from pkgs/idv/src/provider.ts. Swap providers
with one registration call at boot — portal code unchanged.
Cutover (separate ops PR — not in this commit):
1. Tag + push image ghcr.io/hanzoai/id:0.1.0
2. Apply k8s manifests, cert-manager issues TLS
3. Remove CF Worker routes for hanzo.id/lux.id/zoo.id/pars.id
4. CF A records → 129.212.164.5 (hanzo ingress LB)
5. Archive hanzo.id-worker repo
5.5 KiB
5.5 KiB
LLM.md — Hanzo ID
What this is
White-label login + identity verification portal. Vite SPA, served from the Hanzo K8s cluster, white-labels per hostname.
Replaces:
~/work/hanzo/hanzo.id-worker(Cloudflare Worker) — being decommissioned~/work/hanzo/id/legacy-nextjs/(Next.js 15) — frozen, kept for diff
Architecture
DNS → hanzo cluster ingress (129.212.164.5)
hanzo.id ──┐
lux.id ──┤ ─ TLS → ingress ─ K8s ─→ Service id ─→ Deployment id (2 replicas)
zoo.id ──┤ (Traefik) ghcr.io/hanzoai/id:vX.Y.Z
pars.id ──┘ │
│ on boot:
│ resolveTenant(hostname)
│ loadBrand(tenant.brandPackage)
▼
@hanzo|luxfi|zooai|parsdao /brand
│
▼
createAuthClient(tenant)
│
▼
https://iam.hanzo.ai (Casdoor fork, Go)
│
▼
iam-* postgres in hanzo namespace
Workspace
apps/
web/ @hanzo/id-web — Vite + React 19 + @hanzo/gui SPA
pkgs/
shared/ @hanzo/id-shared — TenantConfig, resolveTenant, loadBrand
auth/ @hanzo/id-auth — composable login/signup/OTP forms +
AuthClient (wraps @hanzo/iam REST)
idv/ @hanzo/id-idv — pluggable identity verification
(Persona, Onfido, Veriff, stub)
legacy-nextjs/ Frozen predecessor. Delete after v0.1.0 ships.
Why this layout (and not just Next.js)
- Vite > Next.js for an SPA. No SSR needed; auth is post-load only. ~200kb gzip vs ~600kb. Build is 3s vs 90s.
- @hanzo/gui v7 is the canonical UI. Same shell as every other Hanzo admin surface. No bespoke components.
- Per-org brand packages.
@hanzo/brand,@luxfi/brand,@zooai/brand,@parsdao/brandalready shipbrand.jsonfiles; we fetch them at runtime. Adding a brand =pnpm add @newco/brand- one line in
pkgs/shared/src/tenant.ts(or a runtime catalog entry — no rebuild).
- one line in
- Provider-pluggable IDV. Same surface for Persona, Onfido, Veriff, custom backends. No vendor lock-in at the portal layer.
- Mirrors
a downstream consumer. Sameapps/+pkgs/pattern, same@hanzo/guishell, same per-tenant brand resolution.
Local dev
pnpm install
pnpm dev # http://localhost:5173 → defaults to hanzo brand
For multi-tenant preview:
echo "127.0.0.1 lux.id zoo.id pars.id" | sudo tee -a /etc/hosts
then visit http://lux.id:5173 etc.
Build + deploy
pnpm build
docker build -t ghcr.io/hanzoai/id:0.1.0 .
docker push ghcr.io/hanzoai/id:0.1.0
kubectl apply -k apps/web/k8s
Adding a new brand
pnpm add -F @hanzo/id-web @newco/brand- Add
TenantConfigfor the hostname inpkgs/shared/src/tenant.ts(or put it inIAM_TENANT_CONFIG_JSONat runtime — no rebuild). - Add the hostname to
BRAND_PACKAGESinapps/web/vite.config.ts. - Add host + TLS secret to
apps/web/k8s/ingress.yaml. - DNS → cluster ingress IP.
Plugging an IDV provider
import { registerProvider, createPersonaProvider } from '@hanzo/id-idv'
registerProvider(createPersonaProvider({ templateId, apiKey, environment: 'production' }))
Pre-built providers
| id | source | docs |
|---|---|---|
stub |
@hanzo/id-idv/providers/stub |
in-memory, dev-only |
persona |
@hanzo/id-idv/providers/persona |
https://docs.withpersona.com |
onfido |
@hanzo/id-idv/providers/onfido |
https://documentation.onfido.com |
veriff |
@hanzo/id-idv/providers/veriff |
https://developers.veriff.com |
Custom providers: implement the IDVProvider interface in
pkgs/idv/src/provider.ts and register it.
Cutover from the CF Worker
- Build + push image (PR scaffolds; image bump comes after CI green).
kubectl apply -k apps/web/k8s— Deployment + Service + Ingress live.- cert-manager issues TLS for all 4 hosts.
- Remove the Cloudflare Worker routes for the 4 identity hosts.
- Repoint CF A records:
hanzo.id,lux.id,zoo.id,pars.id→129.212.164.5(hanzo cluster ingress LB), CF-proxied. - Verify each host loads its own brand.
- Archive
hanzo.id-workerrepo.
Backend
The Go IAM backend lives at ~/work/hanzo/iam (Casdoor fork, module
github.com/hanzoai/iam, image ghcr.io/hanzoai/iam). This portal talks
to it via the routes in pkgs/auth/src/client.ts:
/v1/iam/login/v1/iam/signup/v1/iam/send-verification-code/oauth/authorize/oauth/token/oauth/logout
All hostnames talk to the same IAM backend — the org is carried in the
request body (organization: <orgId>), and the IAM backend tenant-scopes
on that.