gitoria
All repositories: gitoria
6.0 KB
# W41 report — gitoria#41 repo owners can connect an app (branch w41-apps-connect, worktree W41/wt, base 06d622d)## BuiltOne commit `9af07ec` "gitoria#41: connect an app to a repo …" (not pushed, not deployed, no ticket written).- `lib/apps.hl`: table `apps.db` keyed by the repo's id (`repo`), rows {repo, name, hookUrl, keyHash (sha256 of gak_+40 hex), secret (64 hex, server only), createdBy, created, lastDelivery, lastStatus}; one row per (repo, name, case-insensitive), re-connect keeps the app id and replaces key + secret; `appOfKey(key)`; `removeApp` (row gone = key dead); `rotateSecret`; `addApp` (manual way B); `makeCode`/`exchangeCode` (table `appcodes.db`, only sha256 of the 48-hex code, deleted on first use, 5 minutes, only on the address of its own repo). Max 20 apps per repo.- `lib/apps-helpers.hl`: URL allow-list, `GITORIA_APP_HOSTS` config (default empty), key shape, `apiOf(slug)`, form parsing.- `lib/api.hl` (thin wrappers) + `lib/api-helpers.hl` `apiError` (contract §6 shape) + `project.hl` routes: `GET /settings/apps/connect` (and `/:orepo/…`), `POST /settings/apps/confirm`, `POST /api/apps/exchange`, `/api/:orepo/apps/exchange`, `/:orepo/api/apps/exchange`.- `components/settings.hl`: "Apps" section (owner: list with name, receiver host, added, last delivery status; Rotate secret; Remove; Add form; key/secret shown once in the page state of that click; the confirm card "Connect X to repo?" with Yes/No). Styles nested, one declaration per line, id rules.- Hook point: `pingAfterConnect(app, repo)` in `lib/apps.hl`, called after an exchange and after a manual Add; sends nothing (for gitoria#43).- README: env var `GITORIA_APP_HOSTS`, section "Apps". `tests/apps.mjs` (95 checks) added to GATES in deploy.sh.## Connect flow as builtApp sends browser → `/settings/apps/connect?app&hook&return&state`: hook/return checked (400 `invalid_url`), name/state checked (422 `invalid`), request parked in the session with a nonce (a session is minted if none) → redirect to the repo's `/settings` → signed out: "Sign in with the selector at the top"; the login callback keeps the same session so the card appears after sign-in; non-owner: "Only the owner…"; owner: Yes/No as a plain HTML form POST with the nonce (no hand-written JS) → `return?code&state` (No: `return?error=denied&state`). The owner check (`ownsRepo`) and the nonce are repeated at the POST; a wrong try does not use up the parked request. Exchange answers the §1 step 3 JSON.Allow-list: https + host `worldapi.org`/subdomain (no port, no user info, no IP, plain ASCII, ≤500 chars, lower-case `https` only), or url == base or starts with base + "/" from `GITORIA_APP_HOSTS` (plain http included, per Apollo's correction and contract v1.1). Tested: `http://100.77.141.84:8100.evil`, `:81000`, other ports, `worldapi.org.evil.com`, `evilworldapi.org`, `x.worldapi.org\@evil.com`, spaces, ftp, javascript:, empty all refused for both hook and return.## Tests (LC_ALL=C, ports 8730–8739, all free before and after)- `node tests/apps.mjs` 95 passed, 0 failed (new gate; flow, allow-list incl. 38 refusal checks, owner-only, re-connect, add/rotate/remove, org repo `acme/rev` with both exchange spellings, no key/secret/code in any page or the server log).- `node theme/check-theme.mjs .` 0 problems (58 files).- `node tests/browser.mjs` 265 passed, 0 failed (rerun with Chrome ports 8733-8738; the first run crashed with "no bindable port in 8735-8738" because I gave it only 4 Chrome ports, not a test failure).- signin-return 3/0, security 82/0, private 158/0, ident-access-gitoria 30/0 (these four are deploy.sh GATES).- Logs: W41/gates.log, W41/apps1.log.## Contract pointsCovered: §0 key/secret/api-base shapes; §1 flow A steps 1–3 and manual B, re-connect replaces, remove, rotate, allowed URLs (v1.1), §6 error shape for the routes I added.Not covered (by scope): step 4 ping (hook point only), tokens gat_ (#42), events/deliveries (#43), rate limits/413 (#47). `lastDelivery`/`lastStatus` stay empty ("no delivery yet").Deviations/choices to confirm: (1) an unknown, used, expired or wrong-repo code is `404 not_found` (the contract has no `invalid_code`). (2) The org exchange route: contract says `{repo address}/api/apps/exchange` (= `<org>/<repo>/api/apps/exchange`) but the API base for org is `<org>/api/<repo>`; I serve both. (3) The confirm card lives on `/settings` (not a separate page), because the login `next` keeps only the path. (4) Uppercase `HTTPS://` is refused (strict).## DOCS/GAP- GAP-1: `JSON.parse` of broken JSON ends the request with 500 (located error), no safe parse, no `req.json()`. Repro: `curl -XPOST -d '{broken' http://host/api/apps/exchange` → 500. Only a body not shaped like `{…}` gets the contract's 400 `invalid_json`; `{broken}` still 500. No workaround added.- GAP-2: a page component cannot read the query string and `route.path` has no query, so `?next=` of the login loses it; solved by parking in the session (fine, but a framework way would be shorter).- DOCS: a View `if` refuses `x != ''` ("declare it at the root"): needed `hasShownKey`.## Open risks / not done- NOT proven in his Chrome on lisbeth :9223 (WORKER-RULES "proof in his Chrome", multi-resolution screenshots). Only the headless gate (real HTTP, plus browser.mjs for existing pages) ran; no screenshot of the new Apps section was taken or looked at. The Add/Rotate/Remove face handlers are tested through the face endpoint, not by clicks in a browser. A follow-up must click Add/Rotate/Remove and the Yes form at 390 px and 1280 px.- The expiry of the 5-minute code is coded (`codeLifeMs`) but not tested (no clock control).- `appOfKey` has no caller yet (#42).- `secret` is stored plain in `apps.db` (server must sign); the face of Add/Rotate sends it to the owner's page once, by design.- The worktree's `bin` is a symlink to the main checkout's bin (not committed; `git status` clean).- Stopped: nothing left running (gates stop their own servers; `ss` shows no 873x listener, no Chrome with a W41 cwd). I started no background processes.- Requests used: about 40.
Branches
Latest commits
- fe209ffeMerge branch 'w56-owner-members' into mainGitoria
- fa0754c8|||PR repository owner transfer and members API (#55)mre
- 8862e537Merge branch 'w55-rename-org' into mainGitoria
- 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
- 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
- 499f25f2Review fixes for the Settings organization move (#53)mre
- ed3b922b|||PR move a repository into an organization in Settings (#53)mre
- 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
- 9f7ce8d8Preserve rename compatibility and live page titlesmre
- c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
- ce08920dMerge branch 'w52c-header-phone' into mainGitoria
- 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
- e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
- c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
- 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
- 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
- 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
- 155861f6Merge branch 'w52-person-approval' into mainGitoria
- b5435de8|||PR person approvals: second Kunibert round (#52)mre
- 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre