Phase 1: identity, sessions, audit, frontend shell

AD sign-in over LDAPS (search with the service account, bind as the user,
nested groups through LDAP_MATCHING_RULE_IN_CHAIN, disabled accounts refused),
roles as the union of PS-* groups mapped by a table derived from the seeded
departments. Server-side sessions with idle, lock and absolute timeouts, Origin
and X-Requested-With check, step-up unlock. Optional Argon2id PIN set with the
domain password; PIN sign-in by employee ID on registered devices only; five
wrong attempts disable the PIN, three wrong at unlock or signature end the
session. Rate limits per account and per address before any bind. Devices,
signatures table and sign helper, audit rows for every identity event, SSE over
LISTEN/NOTIFY with presence. Account settings and Admin APIs and screens
(AD view, devices, PIN clearing, group map with missing-group flags, refresh
from AD now). CLI ad-groups --list and ad-refresh. Migration 0002.

Frontend: real sign-in (password tab, PIN keypad on registered devices), lock
screen, role switcher, Account settings, Admin shell, screen placeholders.

CI: Samba AD DC container (PSTEST.LOCAL) with a generated CA, 49 of the 50
groups plus one extra, 17 test users; wired into the CI compose overlay and
the Gitea workflow; Playwright sign-in scenario.

Verified on docker-1: 171 server tests green inside the CI stack against
PostgreSQL and the Samba DC, 48 frontend tests, 8 Playwright scenarios against
the live stack (password and PIN sign-in, lock and unlock, Admin group map).
Findings recorded in the docs: the DC needs CAP_SYS_ADMIN, a hidden tab locks
only after a minute as the old build did,
and the app uses the alias ps-app for Playwright because "app" is on
Chromium's HSTS preload list.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
2026-10-16 07:40:29 -06:00
co-authored by Claude Fable 5.1
parent 0b663bb2b2
commit 97b0973130
95 changed files with 9609 additions and 183 deletions
+14 -13
View File
@@ -1,7 +1,8 @@
# CI stack settings. Committed on purpose: it holds no secret.
# Secrets come from ci/ci-secrets/, made fresh by ci/make-secrets.sh on every run.
# Relative paths resolve against deploy/, the compose project directory.
# CI never reaches VISUAL, M-Files, AD or the mail relay. Phase 1 adds the Samba DC and fixtures.
# CI never reaches VISUAL, M-Files, PESCO's AD or the mail relay. LDAP goes to the throwaway
# Samba DC in compose.ci.yaml.
# ---- Compose (read by docker compose; also passed to the containers, which ignore them) ----
# Compose project name. Keeps prod and test volumes apart.
@@ -25,7 +26,7 @@ SITE_ID=PESCO
# Site time zone for schedules and display. Containers run in UTC.
SITE_TZ=America/Denver
# Public URL, used in links and mail.
PUBLIC_URL=http://app:8000
PUBLIC_URL=http://ps-app:8000
# Only this container may set X-Forwarded-*. The app re-resolves it. Empty trusts nobody.
TRUSTED_PROXY_HOST=
# DEBUG, INFO, WARNING or ERROR. Logs go to stdout.
@@ -59,24 +60,24 @@ ASSETS_DIR=/data/assets
# Built frontend. Compose sets it too.
STATIC_DIR=/app/static
# ---- LDAP (PESCO Active Directory; CI gets the Samba DC in phase 1) ----
# Both domain controllers, tried in order.
LDAP_URL=
# ---- LDAP (the throwaway Samba DC from deploy/samba, domain PSTEST.LOCAL; never PESCO's AD) ----
# The DC's alias on the backend network. LDAPS with the CA it generates on first start.
LDAP_URL=ldaps://dc1.pstest.local:636
# Search base for users.
LDAP_BASE_DN=
# Service account for searches.
LDAP_BIND_DN=
LDAP_BASE_DN=DC=pstest,DC=local
# Service account for searches. seed.sh sets its password from the ldap_bind_password secret.
LDAP_BIND_DN=CN=svc-packetstation,OU=System_Accounts,OU=Admin,DC=pstest,DC=local
# Service account password, from the compose secret.
LDAP_PASSWORD_FILE=/run/secrets/ldap_bind_password
# User search filter. {0} is the escaped sign-in name.
LDAP_USER_FILTER="(|(sAMAccountName={0})(userPrincipalName={0}))"
# OU that holds the 50 PS-* groups.
LDAP_GROUP_BASE_DN=
# CA chain used to verify the controllers.
LDAP_CA_BUNDLE=/etc/ssl/pesco/ca.pem
# OU that holds the PS-* groups (49 of the 50 plus one extra, on purpose).
LDAP_GROUP_BASE_DN=OU=PacketStation,OU=Groups,OU=PESCO_FARMINGTON,DC=pstest,DC=local
# The DC's CA, from the ci-dc-export volume mounted at /etc/ssl/pstest.
LDAP_CA_BUNDLE=/etc/ssl/pstest/ca.pem
# false with ldaps://. true only with ldap:// on 389.
LDAP_STARTTLS=false
# Never true outside local development.
# Never true outside local development. The DC refuses plain LDAP simple binds anyway.
LDAP_ALLOW_INSECURE=false
# ---- Mail (relay app-03, no auth) ----
+5 -1
View File
@@ -2,7 +2,8 @@
# Make throwaway secrets for a CI or local end-to-end run of compose.ci.yaml.
# Every value is random and new on each run. Nothing here is ever committed:
# deploy/ci/ci-secrets/ and deploy/ci/ci-backups/ are gitignored and dockerignored.
# Also makes an empty CA bundle placeholder (phase 1 swaps in the Samba DC's CA)
# Also makes an empty CA bundle placeholder for the base stack's /etc/ssl/pesco mount
# (LDAP in CI uses the Samba DC's own CA from the ci-dc-export volume instead)
# and an empty backup folder for the worker's read-only mount.
set -euo pipefail
@@ -26,6 +27,9 @@ do
rand > "$out/$name"
done
# Samba DC Administrator. Samba wants upper, lower, digits and a symbol.
printf 'Ci-%s-Adm!' "$(rand)" > "$out/samba_admin_password"
: > "$out/ca.pem"
# CI only: the containers run as uid 10001 and uid 999 (postgres), not as the runner's