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
+95 -27
View File
@@ -1,13 +1,23 @@
# Overlay for CI and local end-to-end runs. Builds the image from this checkout
# instead of pulling it, and reads throwaway secrets made by ci/make-secrets.sh.
# Adds the throwaway Samba AD DC (deploy/samba/) and the Playwright runner (profile e2e).
#
# deploy/ci/make-secrets.sh
# docker compose -p packetstation-ci --env-file deploy/ci/ci.env \
# -f deploy/compose.yaml -f deploy/compose.ci.yaml up -d --build --wait
# docker compose -p packetstation-ci -f deploy/compose.yaml -f deploy/compose.ci.yaml down -v
# -f deploy/compose.yaml -f deploy/compose.ci.yaml up -d --build --wait --wait-timeout 300
# docker compose -p packetstation-ci --env-file deploy/ci/ci.env \
# -f deploy/compose.yaml -f deploy/compose.ci.yaml --profile e2e run --rm playwright
# docker compose -p packetstation-ci --env-file deploy/ci/ci.env \
# -f deploy/compose.yaml -f deploy/compose.ci.yaml down -v
#
# Never combine this overlay with compose.proxy.yaml.
x-logging: &logging
driver: json-file
options:
max-size: "10m"
max-file: "5"
x-build: &build
context: ..
dockerfile: Dockerfile
@@ -19,40 +29,98 @@ services:
build: *build
image: ${IMAGE:-packetstation:ci}
pull_policy: build
volumes:
- ci-dc-export:/etc/ssl/pstest:ro # the DC's CA, LDAP_CA_BUNDLE=/etc/ssl/pstest/ca.pem
app:
build: *build
image: ${IMAGE:-packetstation:ci}
pull_policy: build
volumes:
- ci-dc-export:/etc/ssl/pstest:ro
# Playwright reaches the app as ps-app, never as "app": "app" is a top-level domain on
# Chromium's HSTS preload list, so http://app:8000 is forced to TLS and fails.
networks:
backend:
aliases:
- ps-app
egress: {}
depends_on:
samba-dc:
condition: service_healthy
worker:
build: *build
image: ${IMAGE:-packetstation:ci}
pull_policy: build
volumes:
- ci-dc-export:/etc/ssl/pstest:ro
# Phase 1: Samba AD DC (PSTEST.LOCAL) so LDAP sign-in runs over real TLS in CI.
# Built from deploy/samba/. Its generated CA becomes LDAP_CA_BUNDLE.
# samba-dc:
# build:
# context: ./samba
# hostname: dc1
# networks:
# backend:
# aliases: [dc1.pstest.local]
# healthcheck:
# test: ["CMD", "/usr/local/bin/healthcheck.sh"]
# interval: 10s
# retries: 30
# Throwaway Samba AD DC (PSTEST.LOCAL) so LDAP sign-in runs over real TLS in CI.
# Built from deploy/samba/. Runs as root, as Samba needs. No published port.
# The app reaches it as ldaps://dc1.pstest.local:636 on the internal backend network.
# It writes ca.pem, users.json and seeded to ci-dc-export.
samba-dc:
build:
context: ./samba
image: packetstation-samba-dc:ci
pull_policy: build
hostname: dc1
networks:
backend:
aliases:
- dc1.pstest.local
secrets:
- samba_admin_password
- ldap_bind_password
volumes:
- ci-dc-data:/var/lib/samba
- ci-dc-export:/export
# Provisioning sets NT ACLs on sysvol, which needs security.* xattrs and therefore
# CAP_SYS_ADMIN (verified on docker-1, Samba 4.17: without it the provision step fails).
cap_add:
- SYS_ADMIN
security_opt:
- no-new-privileges:true
healthcheck:
test: ["CMD", "/usr/local/bin/healthcheck.sh"]
interval: 10s
timeout: 10s
retries: 30
start_period: 120s
restart: "no"
logging: *logging
# Phase 1: Playwright runner. Joins backend and drives the app at http://app:8000.
# playwright:
# image: mcr.microsoft.com/playwright:<pinned version>
# working_dir: /work/tests/e2e
# volumes:
# - ../tests/e2e:/work/tests/e2e
# networks:
# backend: {}
# depends_on:
# app:
# condition: service_healthy
# profiles: ["e2e"]
# Playwright runner. Drives the app at http://ps-app:8000 over backend.
# Also on egress, because npm ci fetches @playwright/test from the public registry
# and backend is internal. The image tag must match @playwright/test in tests/e2e/package.json.
playwright:
image: mcr.microsoft.com/playwright:v1.64.1-noble
profiles: ["e2e"]
working_dir: /work/tests/e2e
environment:
E2E_BASE_URL: http://ps-app:8000
E2E_DC_USERS_FILE: /export/users.json
CI: "true"
volumes:
- ../tests/e2e:/work/tests/e2e
- /work/tests/e2e/node_modules # anonymous volume: node_modules stays out of the checkout
- ci-dc-export:/export:ro
networks:
backend: {}
egress: {}
depends_on:
app:
condition: service_healthy
init: true
shm_size: 1g
command: ["sh", "-c", "npm ci --no-audit --no-fund && npx playwright test"]
logging: *logging
volumes:
ci-dc-data: {}
ci-dc-export: {}
secrets:
samba_admin_password:
file: ${SECRETS_DIR:?set SECRETS_DIR in the stack env file}/samba_admin_password