Phase 4: documents, encrypted on the server
Scans and photos of a person's papers, and a company's documents for the extension packs, uploaded on a dashed strip that takes dropped files: up to 10 files of 20 MB each, 64 MB in all; PDF, JPEG, PNG and WebP, told by their first bytes. - src/files.rs: one file per document as <id>.vdoc, AES-256-GCM under a key per file (HKDF-SHA256 from the file key and a random salt in the header); the document's id is authenticated with it. The key comes from VISA_FILES_KEY_FILE or the credential files-key; with the login on, the app does not start without it and VISA_FILES_DIR. - migrations/0003: documents (a person's or a company's, the record it belongs to, kind, date on it, note, file name, type, size, SHA-256); audit_log gets company_id and the action download. - A Documents tab per person, the documents on the company's page, and each record's documents next to its Edit link with "+ Document". - An upload's form token is its first field and is checked before any file is read; the guard lets multipart through only to the two upload addresses. - Files open under their own CSP and are never cached; a download is named after the person or company, the kind and the date. Every upload, view, download, change and deletion is in the audit log. - visa files-check; demo documents in seed-demo; scripts/dev.sh keeps the local documents and their key in .dev/; /favicon.ico for image and PDF pages. Tests: 57 unit and 33 integration (8 new for documents). Edge check of the strip (choose, drop, too large), an upload, the PDF and image viewers under the file policy: no problems, no console errors.
This commit is contained in:
1 parent
d543c929e9
commit
2061e3a024
35 files changed
+4256
-58
No files matched your search
@@ -18,7 +18,7 @@ view and change of a person's record goes into an append-only activity log
|
||||
that names the fields changed but never their values, as Thailand's Personal
|
||||
Data Protection Act (PDPA) asks.
|
||||
|
||||
## What works now (phases 1 and 2)
|
||||
## What works now (phases 1 to 4)
|
||||
|
||||
- The Deadlines page: every person's coming deadlines, the most urgent
|
||||
first, with a filter by employer. It covers the 90-day report with its
|
||||
@@ -26,10 +26,15 @@ Data Protection Act (PDPA) asks.
|
||||
a decision to collect, overstay, TM.30 after each arrival, the passport's
|
||||
and the work permit's expiry, and visas still to be used.
|
||||
- A list of people with a filter and each person's next deadline, and a
|
||||
page per person with three tabs: the overview with personal details,
|
||||
page per person with four tabs: the overview with personal details,
|
||||
passports and addresses; "Visa and stay" with arrivals and departures,
|
||||
extensions, 90-day reports, visas, re-entry permits and work permits; and
|
||||
the person's activity.
|
||||
extensions, 90-day reports, visas, re-entry permits and work permits; the
|
||||
person's documents; and the person's activity.
|
||||
- Documents: scans and photos of the passport pages, the TDAC, receipts and
|
||||
the photo, dropped on a dashed strip, several at a time, and filed under
|
||||
the record they belong to. A company keeps its own documents for the
|
||||
extension packs. The files are encrypted on the server, open in the
|
||||
browser's viewer, and every upload, view and download is in the log.
|
||||
- Companies with their Thai name, registration number (the check digit is
|
||||
verified), address and signing director. A person's employer and the
|
||||
employer on a work permit are chosen from them, and a company's page adds
|
||||
@@ -53,8 +58,10 @@ bash scripts/dev.sh # http://127.0.0.1:8040, no login, demo pe
|
||||
```
|
||||
|
||||
`scripts/dev.sh` runs without a login (`VISA_INSECURE_NO_LOGIN=1`, which the
|
||||
app accepts only on a loopback address) and adds invented demo people. The
|
||||
demo command refuses to run when a login provider is configured.
|
||||
app accepts only on a loopback address) and adds invented demo people with
|
||||
demo documents. The documents and their key lie in `.dev/`, which git
|
||||
ignores. The demo command refuses to run when a login provider is
|
||||
configured.
|
||||
|
||||
The tests need the same database; each test gets its own:
|
||||
|
||||
@@ -79,9 +86,17 @@ files or systemd credentials and never from a variable's value.
|
||||
| `VISA_OIDC_CLIENT_SECRET_FILE` | the client secret; else the credential `oidc-client-secret` |
|
||||
| `VISA_OIDC_GROUP` | default `visa` |
|
||||
| `VISA_INSECURE_NO_LOGIN` | `1` runs without a login, on loopback addresses only |
|
||||
| `VISA_FILES_DIR` | where the encrypted documents lie (`/var/lib/visa/files`) |
|
||||
| `VISA_FILES_KEY_FILE` | the file key, 64 hex digits; else the credential `files-key` |
|
||||
|
||||
With the login on, the app does not start without the files directory and
|
||||
the file key. Local development may go without them, and documents are then
|
||||
switched off. The key never changes: the files cannot be read without it.
|
||||
|
||||
`visa serve` (the default) applies pending migrations before it listens,
|
||||
`visa migrate` applies them alone, and `visa seed-demo` adds the demo people.
|
||||
`visa migrate` applies them alone, `visa seed-demo` adds the demo people and
|
||||
documents, and `visa files-check` reads every document's file back, compares
|
||||
it with its upload and lists files that belong to no document.
|
||||
|
||||
## Where it runs
|
||||
|
||||
|
||||
Reference in new issue
Block a user