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.
44 lines
990 B
Rust
44 lines
990 B
Rust
//! The Activity page: the audit log, newest first.
|
|
|
|
use std::sync::Arc;
|
|
|
|
use axum::Extension;
|
|
use axum::extract::{Query, State};
|
|
use axum::http::StatusCode;
|
|
use minijinja::context;
|
|
use serde::Deserialize;
|
|
|
|
use super::{AppState, Res};
|
|
use crate::audit;
|
|
use crate::people;
|
|
use crate::session::User;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct ActivityQuery {
|
|
#[serde(default)]
|
|
person: Option<i64>,
|
|
}
|
|
|
|
pub async fn page(
|
|
State(st): State<Arc<AppState>>,
|
|
Extension(user): Extension<User>,
|
|
Query(q): Query<ActivityQuery>,
|
|
) -> Res {
|
|
let items = audit::recent(&st.db, q.person, 300).await?;
|
|
let person = match q.person {
|
|
Some(id) => people::get_person(&st.db, id)
|
|
.await?
|
|
.map(|p| context! { id => p.id, name => p.display_name() }),
|
|
None => None,
|
|
};
|
|
Ok(super::page(
|
|
&st,
|
|
&user,
|
|
"activity.html",
|
|
"Activity",
|
|
"activity",
|
|
StatusCode::OK,
|
|
context! { items, person },
|
|
))
|
|
}
|