Phase 1: app, Kanidm login, people, passports, addresses, audit log
CI / secret scan (push) Successful in 4s
CI / fmt, clippy, tests (push) Successful in 42s

visa.buildfor.life keeps the immigration records of the foreigners B4L
looks after. This first phase is the base the deadlines and extension
packs build on (docs/PLAN.md, phases 2 to 7).

- One Rust binary (axum 0.8, minijinja, sqlx on PostgreSQL) with its
  templates, static files and migrations compiled in.
- Login through Kanidm (OpenID Connect with PKCE and a nonce, ES256),
  client visa-web, group visa; sessions in PostgreSQL keyed by the
  SHA-256 of the cookie. VISA_INSECURE_NO_LOGIN=1 for loopback
  development only.
- Same-site check and form token on every POST; a CSP without inline
  script or style; security headers.
- People: list with filter, page, create, edit, archive, restore.
- Passports from the machine-readable zone with check digits (ICAO
  9303 TD3); expiry warnings at 12 and 6 months.
- Addresses in Thailand in the order Thai forms use, with the house
  master and the TM.30 receipt.
- Append-only audit log of every view and change, with the names of the
  changed fields but never their values (PDPA); the Activity page.
- Invented demo people (visa seed-demo, refused when login is on).
- 40 tests: unit tests, pages with demo data, the forms, the audit log
  and the whole login against a fake OpenID provider.
- CI: gitleaks over the history, fmt, clippy and the tests against
  PostgreSQL 18; the pre-commit secret scan.
This commit is contained in:
grabowski committed 2026-11-17 16:58:48 +07:00
commit 2e009700a9
56 files changed
+11193

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
// Theme switch, the list filter and delete confirmations. Event delegation
// and no inline handlers: the Content Security Policy allows no inline script.
(function () {
"use strict";
// ---- theme: <html data-theme="light|dark">, kept in localStorage
document.addEventListener("click", function (ev) {
var b = ev.target.closest && ev.target.closest("#themeBtn");
if (!b) return;
var root = document.documentElement;
var next = root.getAttribute("data-theme") === "light" ? "dark" : "light";
root.setAttribute("data-theme", next);
try {
localStorage.setItem("visa-theme", next);
} catch (e) {
/* storage blocked */
}
});
// ---- forms with data-confirm ask first (archive, delete)
document.addEventListener("submit", function (ev) {
var f = ev.target;
var msg = f && f.getAttribute && f.getAttribute("data-confirm");
if (msg && !window.confirm(msg)) ev.preventDefault();
});
// ---- filter: rows carry data-q (lower case); "/" focuses the box
function applyFilter() {
var box = document.getElementById("q");
if (!box) return;
var q = box.value.trim().toLowerCase();
var rows = document.querySelectorAll("[data-q]");
var shown = 0;
rows.forEach(function (el) {
var hit = q === "" || el.getAttribute("data-q").indexOf(q) !== -1;
el.hidden = !hit;
if (hit) shown++;
});
document.querySelectorAll("[data-filter-empty]").forEach(function (el) {
el.hidden = q === "" || rows.length === 0 || shown > 0;
});
}
document.addEventListener("input", function (ev) {
if (ev.target && ev.target.id === "q") applyFilter();
});
document.addEventListener("keydown", function (ev) {
var box = document.getElementById("q");
if (!box) return;
var tag = document.activeElement ? document.activeElement.tagName : "";
if (ev.key === "/" && !/^(INPUT|TEXTAREA|SELECT)$/.test(tag)) {
ev.preventDefault();
box.focus();
} else if (ev.key === "Escape" && document.activeElement === box) {
box.value = "";
applyFilter();
box.blur();
}
});
document.addEventListener("DOMContentLoaded", applyFilter);
})();