P0 Foundations: server, auth, web shell, Docker image, CI #1

Closed
xpltd_admin wants to merge 0 commits from feature/p0-foundations into main
Owner

Phase 0 of docs/PLAN.md: the base every later phase builds on.

What's in it

  • Technical plan (docs/PLAN.md): stack, how one renderer serves preview, export and decode test, starting scannability thresholds, how the redirect relay works, and the phase breakdown (v1 = P0–P4).
  • Server:
    • TypeScript on Node 22, Fastify 5, SQLite through Drizzle; migrations run automatically on start.
    • All configuration comes from GLYPHLAB_* environment variables (.env.example). /healthz is the health endpoint.
  • Host routing: the app answers only on its own hostnames. Short-link domains are link-only (they return 404 until P2 adds redirects). Any other hostname gets 421.
  • Accounts and sign-in:
    • First-run setup requires a one-time token, printed in the log or set with GLYPHLAB_SETUP_TOKEN. The first user can also be seeded from environment variables.
    • Local accounts use argon2id passwords. Self-signup is opt-in.
    • Failed logins trigger a lockout that grows longer with each failure, applied per username and per IP, plus a rate limit on the login routes.
    • Generic OIDC sign-in (authorization code + PKCE) with an auto-provision switch. An OIDC sign-in never attaches to an existing local account just because the name matches.
    • Sessions are stored server-side and only a hash of the token is kept. Every state-changing request must come from the app's own origin (CSRF check). Strict CSP, plus HSTS when served over HTTPS.
  • Web: React + Vite screens for setup, sign-in and home. The footer carries the QR Code trademark notice.
  • Docker:
    • One image that runs as non-root uid 10101, with the app directory read-only and SUID bits stripped.
    • All data lives in one /data volume. The image has a healthcheck and takes APP_VERSION as a build arg.
  • CI (Forgejo Actions):
    • Every PR and push runs lint, the license audit, typecheck, tests and the build.
    • A second job builds the image and checks the container boots healthy.
    • A tag-triggered workflow publishes a multi-arch (amd64 + arm64) image to the registry.
  • Docs: README quick start, CONTRIBUTING, SECURITY policy, CHANGELOG, generated THIRD_PARTY_NOTICES.

Verification

  • npm run lint && npm run typecheck && npm test: 20 tests pass.
    • The OIDC tests run end to end against a real in-process OpenID provider.
    • The rest cover lockout, CSRF, host routing, the sign-in requirement on API routes, and security headers.
  • Container check: a fresh docker run with only GLYPHLAB_PUBLIC_URL set comes up healthy, serves the first-run screen, runs as uid 10101 and rejects unknown hostnames with 421.

Watch on this PR

  • This is the first use of the runner's host label for the Docker job, because job containers get no Docker socket. If the runner image lacks the Docker CLI or Node, the label needs changing.
  • The publish workflow needs the secrets REGISTRY_USER and REGISTRY_TOKEN before the first v* tag.

🤖 Generated with Claude Code

Phase 0 of `docs/PLAN.md`: the base every later phase builds on. ## What's in it - **Technical plan** (`docs/PLAN.md`): stack, how one renderer serves preview, export and decode test, starting scannability thresholds, how the redirect relay works, and the phase breakdown (v1 = P0–P4). - **Server:** - TypeScript on Node 22, Fastify 5, SQLite through Drizzle; migrations run automatically on start. - All configuration comes from `GLYPHLAB_*` environment variables (`.env.example`). `/healthz` is the health endpoint. - **Host routing:** the app answers only on its own hostnames. Short-link domains are link-only (they return 404 until P2 adds redirects). Any other hostname gets `421`. - **Accounts and sign-in:** - First-run setup requires a one-time token, printed in the log or set with `GLYPHLAB_SETUP_TOKEN`. The first user can also be seeded from environment variables. - Local accounts use argon2id passwords. Self-signup is opt-in. - Failed logins trigger a lockout that grows longer with each failure, applied per username and per IP, plus a rate limit on the login routes. - Generic OIDC sign-in (authorization code + PKCE) with an auto-provision switch. An OIDC sign-in never attaches to an existing local account just because the name matches. - Sessions are stored server-side and only a hash of the token is kept. Every state-changing request must come from the app's own origin (CSRF check). Strict CSP, plus HSTS when served over HTTPS. - **Web:** React + Vite screens for setup, sign-in and home. The footer carries the QR Code trademark notice. - **Docker:** - One image that runs as non-root uid 10101, with the app directory read-only and SUID bits stripped. - All data lives in one `/data` volume. The image has a healthcheck and takes `APP_VERSION` as a build arg. - **CI (Forgejo Actions):** - Every PR and push runs lint, the license audit, typecheck, tests and the build. - A second job builds the image and checks the container boots healthy. - A tag-triggered workflow publishes a multi-arch (amd64 + arm64) image to the registry. - **Docs:** README quick start, CONTRIBUTING, SECURITY policy, CHANGELOG, generated THIRD_PARTY_NOTICES. ## Verification - `npm run lint && npm run typecheck && npm test`: 20 tests pass. - The OIDC tests run end to end against a real in-process OpenID provider. - The rest cover lockout, CSRF, host routing, the sign-in requirement on API routes, and security headers. - Container check: a fresh `docker run` with only `GLYPHLAB_PUBLIC_URL` set comes up healthy, serves the first-run screen, runs as uid 10101 and rejects unknown hostnames with `421`. ## Watch on this PR - This is the first use of the runner's `host` label for the Docker job, because job containers get no Docker socket. If the runner image lacks the Docker CLI or Node, the label needs changing. - The publish workflow needs the secrets `REGISTRY_USER` and `REGISTRY_TOKEN` before the first `v*` tag. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The brief deferred stack, rendering, scannability thresholds, relay design
and phasing to planning; record those decisions as the design of record.
Env-only configuration keeps instance settings out of reach of app users.
Host routing confines the app to its own hostnames and keeps short-link
domains link-only. First-run setup requires a one-time token so a fresh
public instance can't be claimed by a stranger, and OIDC never auto-links
to an existing local account to prevent takeover via the IdP.
Gives the first-run and sign-in flows a real UI and carries the required
QR Code trademark notice in the footer.
Single non-root image with a read-only app dir and healthcheck. CI runs
lint, license audit, typecheck, tests, build and a container boot smoke
test; tagged releases publish multi-arch images. The license allowlist
keeps every shipped dependency redistributable under Apache-2.0.
Document setup, contributing, security policy and project state
All checks were successful
CI / check (pull_request) Successful in 30s
CI / docker (pull_request) Successful in 1m56s
36e79cab11
xpltd_admin referenced this pull request from a commit 2026-11-16 21:03:41 -07:00
Author
Owner

Merged into main as 7451418 (merge commit, pushed directly — the Forgejo MCP has no merge action). Closing.

Merged into `main` as 7451418 (merge commit, pushed directly — the Forgejo MCP has no merge action). Closing.
xpltd_admin closed this pull request 2026-11-16 21:04:14 -07:00
All checks were successful
CI / check (pull_request) Successful in 30s
CI / docker (pull_request) Successful in 1m56s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xpltdco/GlyphlabQR!1
No description provided.