Self-host the edge with AUTH_MODE=none - #317
Open
danperks wants to merge 1 commit into
Open
Conversation
Run the production Worker on your own machine — local workerd via `wrangler dev`, Durable Object and R2 state on a Docker volume, no Cloudflare account, no WorkOS — and have every device pointed at it share one workspace. Edge: a third auth mode, `none`. No bearer is checked; every caller is the fixed identity from SELFHOST_USER_ID / SELFHOST_ORG_ID (default local/local), and /health advertises that identity so clients can adopt it. The mode is open to whoever can reach the port, which docs/SELFHOST.md is blunt about. Ships with a Dockerfile, docker-compose.selfhost.yml, wrangler.selfhost.jsonc (bindings mirror wrangler.jsonc) and an `npm run dev:selfhost` script. Engine: `Auth::detect` now understands `auth: "none"` — it drops WorkOS, takes the edge's userId/orgId as the `user@org` dev bearer, and flags the config as an open edge so the development scope enables sync without an explicit ZERON_EDGE_TOKEN. `build_auth` only probes when ZERON_EDGE_URL was set and WorkOS is off, so a dev boot that names no edge still makes zero network requests (local_first::development_without_an_explicit_bearer_stays_offline holds). Usage: docker compose -f docker-compose.selfhost.yml up --build ZERON_EDGE_URL=http://localhost:8787 ZERON_WORKOS_CLIENT_ID= zeron headless Verified end to end: registry room joined, device-room host connected, and the profile lands in orgs/local/local against both `wrangler dev` and the compose image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Run the production edge Worker on your own machine — local workerd via
wrangler dev, Durable Object and R2 state on a Docker volume, no Cloudflare account, no WorkOS — and have every device pointed at it share one workspace.ZERON_EDGE_URLalready existed "for local dev / self-hosting"; this fills in the rest so it is actually a self-host story rather than a dev-mode one.Edge
AUTH_MODE,none: no bearer is checked, every caller is the fixed identity fromSELFHOST_USER_ID/SELFHOST_ORG_ID(defaultlocal/local)./healthadvertisesuserId/orgIdso clients adopt it without any out-of-banduser@orgcoordination.noneis open to whoever can reach the port.docs/SELFHOST.mdsays so plainly and tells people to keep it on a private network or behind their own auth.edge/Dockerfile,docker-compose.selfhost.yml(volume-backed, healthcheck),edge/wrangler.selfhost.jsonc(bindings and migrations mirrorwrangler.jsonc, with a note to keep them in lockstep),npm run dev:selfhost.edge/src/auth.test.tscovers mode normalisation, identity defaults/overrides, and thatnoneauthenticates with or without a bearer whiledevstill requires one.Engine
Auth::detect(previously only used by tests) now understandsauth: "none": drops WorkOS, takes the edge'suserId/orgIdas theuser@orgdev bearer, and flags the config as an open edge.resolve_profileprefers that org for the development profile, andassemble_runtimeenables Edge rooms/relays for an open edge even with noZERON_EDGE_TOKEN.build_authprobes only when WorkOS is off andZERON_EDGE_URLis set. A dev boot that names no edge still makes zero network requests —local_first::development_without_an_explicit_bearer_stays_offlineis unchanged and passing. A clean WorkOS boot is untouched.engine/tests/auth.rs: identity adoption from anoneedge (overriding a configured dev bearer), and an unreachable edge leaving the configured dev identity alone.Verification
npm testinedge/(unit + workerd),cargo test -p zeron-engineall green.npm run dev:selfhostand the compose image: engine logsauth: edge is open (AUTH_MODE=none), registry room joins underorg=local, device-room host connects, profile lands inorgs/local/local. Compose healthcheck goes healthy.Not in this PR
A locked-down self-host mode (device tokens + QR pairing for phones) is a separate feature and will follow once this lands. Release mirroring for
zeron updateagainst a self-hosted edge is documented as unsupported for now.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.