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

+59
View File
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% import "_fields.html" as fm %}
{% block main %}
{% if p %}
{% include "_person_head.html" %}
{% else %}
<div class="crumbs"><a href="/people">People</a></div>
<div class="pagehead"><h1>New person</h1></div>
{% endif %}
<form method="post" action="{{ action }}" class="form" id="person-form">
<input type="hidden" name="csrf" value="{{ csrf }}">
<button type="submit" name="action" value="save" class="default-submit" tabindex="-1" aria-hidden="true">Save</button>
{% if mode == "new" %}
<section class="card" id="mrz-card">
<header><h2>Read the passport</h2></header>
<p class="hint lead">Type or paste the two lines at the bottom of the photo page, then press Read. The form below fills itself in, and the check digits in the lines catch typing errors.</p>
{{ fm.area("mrz", "Machine-readable zone, two lines of 44 characters", pf.mrz, err=errors.mrz, rows=2, cls="mrz") }}
<div class="formactions">
<button type="submit" name="action" value="read-mrz" class="btn" id="read-mrz" formnovalidate>Read</button>
{% if mrz_note %}<p class="okline" role="status">{{ mrz_note }}</p>{% endif %}
</div>
</section>
{% endif %}
<section class="card">
<header><h2>{% if mode == "new" %}Person{% else %}Personal details{% endif %}</h2></header>
<div class="grid">
{{ fm.text("surname", "Surname", f.surname, err=errors.surname, req=true, hint="As printed in the passport.") }}
{{ fm.text("first_name", "First name", f.first_name, err=errors.first_name, req=true) }}
{{ fm.text("middle_name", "Middle names", f.middle_name, err=errors.middle_name) }}
{{ fm.select("title", "Title", f.title, titles, err=errors.title) }}
{{ fm.select("sex", "Sex", f.sex, sexes, err=errors.sex) }}
{{ fm.text("date_of_birth", "Date of birth", f.date_of_birth, err=errors.date_of_birth, type="date") }}
{{ fm.text("place_of_birth", "Place of birth", f.place_of_birth, err=errors.place_of_birth) }}
{{ fm.select("nationality", "Nationality", f.nationality, countries, err=errors.nationality) }}
{{ fm.text("occupation", "Occupation", f.occupation, err=errors.occupation) }}
{{ fm.text("employer", "Employer", f.employer, err=errors.employer, hint="The company named in the work permit.") }}
{{ fm.text("phone", "Phone", f.phone, err=errors.phone, type="tel") }}
{{ fm.text("email", "Email", f.email, err=errors.email, type="email") }}
{{ fm.area("notes", "Notes", f.notes, err=errors.notes, rows=3, fcls="wide") }}
</div>
</section>
{% if mode == "new" %}
<section class="card">
<header><h2>Passport</h2><span class="muted small">Optional here; it can also be added later.</span></header>
<div class="grid">
{{ fm.text("number", "Passport number", pf.number, err=errors.number) }}
{{ fm.select("issuing_country", "Issued by", pf.issuing_country, countries, err=errors.issuing_country, blank="Choose a country") }}
{{ fm.text("issued_on", "Date of issue", pf.issued_on, err=errors.issued_on, type="date") }}
{{ fm.text("expires_on", "Date of expiry", pf.expires_on, err=errors.expires_on, type="date") }}
{{ fm.text("issued_at", "Authority or place of issue", pf.issued_at, err=errors.issued_at, hint="As printed in the passport.", cls="wide") }}
</div>
</section>
{% endif %}
<div class="formactions">
<button type="submit" name="action" value="save" class="btn pri" id="save">{% if mode == "new" %}Create the person{% else %}Save{% endif %}</button>
<a class="btn ghost" href="{% if p %}/people/{{ p.id }}{% else %}/people{% endif %}">Cancel</a>
</div>
</form>
{% endblock %}