Documents in a bucket of Garage, still encrypted by the app
Asked for on November 19, 2026: the uploaded files land in an S3 bucket of the fleet's Garage instead of a directory on cnx01, as the fleet's other apps keep theirs. The app encrypts each file exactly as before (AES-256-GCM under a key from HKDF, the document's id authenticated), so the bucket holds the same VISADOC1 files and Garage never sees a key or a document in the clear. Garage's SSE-C stays off: its key would come from the same secret. src/s3.rs is a small S3 client on reqwest and ring, as in proplan: SigV4 (checked against AWS's two published examples), path-style PUT, GET, HEAD, DELETE and ListObjectsV2 page by page, three attempts when the server is away or busy. It asks before it writes, so no object is replaced; it sends If-None-Match: * as well, which Garage 2.5 ignores (seen in tests/garage.rs). The store (src/files.rs) keeps the files as documents/<id>.vdoc in the bucket, or as <id>.vdoc in a directory for development and the tests. Its calls are async now. VISA_S3_BUCKET, _ENDPOINT, _REGION and _ACCESS_KEY_ID name the bucket, the secret comes from VISA_S3_SECRET_ACCESS_KEY_FILE or the credential s3-secret; the bucket and a directory together are refused. At the start the app checks the bucket in the background and only warns. New commands: `visa files-migrate --from DIR` copies the files of a directory into the store, each opened and compared with its upload before and after, and may run again; `visa files-mirror --to DIR` makes a directory hold exactly the bucket's files, still encrypted, for the backups, and a restore is files-migrate from it. Tests: an S3 server inside the test process that checks every request's signature and pages its listings (tests/common/fake_s3.rs); uploads, views, downloads and deletions through it, the check finding swapped, missing and stray objects, the move from a directory (again, missing, other bytes, damaged), the mirror and a restore from it, a busy server and a wrong key. tests/garage.rs runs the store against Garage 2.5.0, the version cnx01 runs, which scripts/dev-garage.sh starts in Docker; VISA_DEV_S3=1 scripts/dev.sh runs the dev server on it. The 14 demo documents moved into it with files-migrate and a browser upload landed there.
This commit is contained in:
1 parent
17426dba12
commit
0370e0154f
20 files changed
+2558
-218
No files matched your search
+54
-23
@@ -1,10 +1,11 @@
|
||||
# visa.buildfor.life: plan
|
||||
|
||||
> Phases 1 to 3 built on November 17, 2026, phase 4's app side and phase 5
|
||||
> on November 18, 2026. The live app at https://visa.buildfor.life has phases
|
||||
> 1 to 3 until cnx-network-clan PR #126 (task 4.6) is deployed and the fleet's
|
||||
> `visa` input is updated to the newest commit. **Resume here: phase 6, the
|
||||
> Non-B extension pack.**
|
||||
> Phases 1 to 3 built on November 17, 2026, phases 4 and 5 on November 18,
|
||||
> 2026, all live at https://visa.buildfor.life. On November 19, 2026 the
|
||||
> documents moved from a directory on cnx01 into a bucket of cnx01's Garage
|
||||
> (task 4.8); the app side is built, and the fleet side (task 4.9) goes live
|
||||
> once its cnx-network-clan pull request is deployed. **Resume here: phase 6,
|
||||
> the Non-B extension pack.**
|
||||
|
||||
visa.buildfor.life keeps the immigration records of the foreigners that B4L
|
||||
looks after: their passports, addresses in Thailand, arrivals with the Thailand
|
||||
@@ -25,7 +26,8 @@ The first round of questions was answered on November 17, 2026.
|
||||
|
||||
| Question | Decision |
|
||||
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Where it runs | cnx01, installed on the host like proplan and lampbench: database `visa` on cnx01's PostgreSQL, files in a ZFS dataset, encrypted by the app, borg backups to juliet |
|
||||
| Where it runs | cnx01, installed on the host like proplan and lampbench: database `visa` on cnx01's PostgreSQL, documents in its Garage, encrypted by the app, borg backups to juliet |
|
||||
| Documents in Garage | bucket `visa-documents` on cnx01's Garage, 10 GB (Nov 19, 2026); the app encrypts each file before it leaves the app, so Garage holds no key; Garage's SSE-C is off |
|
||||
| How it is published | bkk01 publishes `visa.buildfor.life` through a `modules/web-sites` app entry |
|
||||
| Login | Kanidm at id.cnx.network, OAuth2 client `visa-web`, group `visa` with grabowski and oltmanns |
|
||||
| Who sees what | every member of `visa` sees and edits every record, as agency staff would; a view for clients comes later |
|
||||
@@ -60,15 +62,19 @@ inline script or style.
|
||||
(PDPA). Every view of a person and every change is written to `audit_log`
|
||||
with the login, the record and the names of the changed fields, never their
|
||||
values. The table refuses updates and deletes. The Activity page lists it.
|
||||
- **Documents.** Scans and photos lie in a files directory on the server,
|
||||
one file per document, encrypted by the app with AES-256-GCM. Each file has
|
||||
a key of its own, derived with HKDF-SHA256 from the app's file key and a
|
||||
random salt in the file's header, and the document's id is authenticated
|
||||
with it, so a file renamed to another document's id does not open. The
|
||||
file key is a systemd credential that is never in the database, so neither
|
||||
the files nor their backups can be read without it. The database holds what
|
||||
is known about each file: its kind, the record it belongs to, the date on
|
||||
it, a note, its name, type, size and SHA-256.
|
||||
- **Documents.** Scans and photos lie in the bucket `visa-documents` of
|
||||
cnx01's Garage, one object per document, encrypted by the app with
|
||||
AES-256-GCM before they leave it. Each file has a key of its own, derived
|
||||
with HKDF-SHA256 from the app's file key and a random salt in the file's
|
||||
header, and the document's id is authenticated with it, so a file renamed
|
||||
to another document's id does not open. The file key is a systemd
|
||||
credential that is never in the database or in Garage, so neither the
|
||||
bucket nor its backups can be read without it. A small S3 client of the
|
||||
app's own (SigV4 signing on reqwest and ring, as proplan does) talks to the
|
||||
bucket and never replaces an object; in local development the same files
|
||||
lie in a directory instead. What is known about each file is in the
|
||||
database: its kind, the record it belongs to, the date on it, a note, its
|
||||
name, type, size and SHA-256.
|
||||
- **Passport data entry.** The two lines of the machine-readable zone (MRZ)
|
||||
at the bottom of the photo page fill the name, nationality, date of birth,
|
||||
sex, passport number, issuing state and expiry date. Their check digits
|
||||
@@ -93,7 +99,7 @@ made of.
|
||||
| `reentry_permits` | TM.8 permits, single or multiple, valid until | 2 |
|
||||
| `ninety_day_reports` | the report date, the way it was filed, the receipt and the next due date printed on it | 2 |
|
||||
| `work_permits` | number, employer (a company), position, validity | 2 |
|
||||
| `documents` | uploads of a person (tied to one of their records, or none) or of a company: kind, date on the document, note, file name, type, size, SHA-256; the file itself is encrypted on disk | 4 |
|
||||
| `documents` | uploads of a person (tied to one of their records, or none) or of a company: kind, date on the document, note, file name, type, size, SHA-256; the file itself lies encrypted in the bucket | 4 |
|
||||
|
||||
## Deadline rules
|
||||
|
||||
@@ -170,7 +176,7 @@ dark at desktop and phone width, a commit and a push.
|
||||
| 1 | App, Kanidm login, people, passports with MRZ reading, addresses in Thailand, audit log, demo data, CI | built Nov 17, 2026 |
|
||||
| 2 | Companies; stays: visas, arrivals with TDAC, extensions, re-entry permits, 90-day reports, work permits; deadlines | built Nov 17, 2026 |
|
||||
| 3 | On cnx01: flake package, fleet module, Kanidm client and group, bkk01 site, backups; real data from here on | live Nov 17, 2026 |
|
||||
| 4 | Documents: encrypted uploads (passport pages, TDAC, receipts, photo) on the dataset `zroot/visa` with a key var, viewing and download, all audited; the office's GPS position and photo | app built Nov 18, 2026; fleet in PR #126 |
|
||||
| 4 | Documents: encrypted uploads (passport pages, TDAC, receipts, photo) in a bucket of cnx01's Garage (first on the dataset `zroot/visa`) with a key var, viewing and download, all audited; the office's GPS position and photo | live Nov 18, 2026; Garage built Nov 19, 2026 |
|
||||
| 5 | Filled-in forms: TM.7, STM.2, the overstay acknowledgment (STM.9), STM.11, STM.1, TM.47 and TM.8 as PDF | built Nov 18, 2026 |
|
||||
| 6 | The Non-B extension pack: B4L's company documents, the checklist, one PDF to print | |
|
||||
| 7 | Reminders by Matrix room message and by email | |
|
||||
@@ -259,13 +265,13 @@ one `Kind`.
|
||||
(`audit_log.company_id`). `visa files-check` reads every file back and
|
||||
lists damaged, missing and stray files. `visa seed-demo` adds demo
|
||||
documents: PDFs marked as demos and PNGs of shapes.
|
||||
- [ ] 4.6 Fleet: the dataset `zroot/visa` at `/var/lib/visa` with the files
|
||||
- [x] 4.6 Fleet: the dataset `zroot/visa` at `/var/lib/visa` with the files
|
||||
in `files/`, the var `visa-files` with the key, the files in cnx01's
|
||||
borg backups, and the VM test uploading a scan through the login. Built
|
||||
and checked in cnx-network-clan PR #126 (branch `visa-files`, opened
|
||||
Nov 18, 2026); Alex merges and deploys it, together with the flake
|
||||
update #125 that cnx01 and control do not run yet. After the deploy:
|
||||
`visa-admin files-check` on cnx01 and an upload on the live app.
|
||||
borg backups, and the VM test uploading a scan through the login
|
||||
(cnx-network-clan PR #126, merged and deployed on November 18, 2026).
|
||||
By November 19 four real documents had arrived on the live app, and
|
||||
`visa-admin files-check` on cnx01 read all four back without a
|
||||
problem.
|
||||
- [x] 4.7 A company's office, asked for on November 18, 2026: its GPS
|
||||
position on the company form, read from the numbers Google Maps
|
||||
copies, a link to the place on Google Maps or OpenStreetMap, or
|
||||
@@ -275,6 +281,31 @@ one `Kind`.
|
||||
of the office, and a strip that adds a photo and returns to the card.
|
||||
The photos are documents of the kind "Photo of the office", so they
|
||||
are encrypted and audited like every other file.
|
||||
- [x] 4.8 Documents in Garage, asked for on November 19, 2026: the files
|
||||
lie in the bucket `visa-documents` of cnx01's Garage instead of the
|
||||
dataset, as the fleet's other apps keep theirs, so the app can later
|
||||
move into a guest of its own without its files. The app encrypts each
|
||||
file exactly as before, so the bucket holds the same `VISADOC1` files
|
||||
and never a key; Garage's SSE-C stays off, since its key would come
|
||||
from the same secret. A small S3 client (`src/s3.rs`, SigV4 on reqwest
|
||||
and ring, as in proplan) asks before it writes, so no object is ever
|
||||
replaced (Garage 2.5 ignores the `If-None-Match: *` it sends as well),
|
||||
and tries a busy server three times. `VISA_S3_*` name the bucket and the key; the secret
|
||||
comes from the credential `s3-secret`. `visa files-migrate --from DIR`
|
||||
copies the files of a directory into the bucket, each opened and
|
||||
compared with its upload before and after, and may run again;
|
||||
`visa files-mirror --to DIR` keeps a copy of the bucket, still
|
||||
encrypted, for the backups, and a restore is `files-migrate` from it.
|
||||
The tests run against an S3 server inside the test that checks every
|
||||
signature (`tests/common/fake_s3.rs`), and `tests/garage.rs` against
|
||||
the Garage version cnx01 runs (`scripts/dev-garage.sh`).
|
||||
- [ ] 4.9 Fleet: the key `visa` and the bucket `visa-documents` (10 GB) in
|
||||
cnx01's Garage, the app's S3 settings, the four live documents moved
|
||||
into the bucket at the first start (`files/` then becomes
|
||||
`files-before-s3`, kept a week), `visa-mirror` before each borg run
|
||||
into `/var/lib/visa/s3-mirror`, and the VM test moving a scan from the
|
||||
directory into the bucket through the deploy. After the deploy:
|
||||
`visa-admin files-check` on cnx01 and an upload on the live app.
|
||||
|
||||
### Phase 5: filled-in forms
|
||||
|
||||
|
||||
Reference in new issue
Block a user