Records package viewer: read-only, no account needed

SAM_VIEWER=true (set only by the records package's
viewer/docker-compose.yml) makes the app a read-only copy of an archive,
for whoever receives the records: `docker compose up`, then open
http://localhost:3000.

- At start (bin/docker-entrypoint → sam:viewer:prepare) the package's
  .sam.zip, mounted read-only, is imported once.
- No sign-in: everyone browses as a built-in account. Nothing can be
  changed: any request but GET/HEAD is refused, no role permission
  applies (so no edit buttons), and there's no sign-out or profile. A
  banner names the archive and when it was exported.
- It refuses to start, and every page answers 503, when the database
  has any other account, so turning it on for a real installation stops
  the app instead of exposing its records.
- The viewer listens on 127.0.0.1 only, and skips scheduled jobs
  (reminders, backups, AD searches).
- Docs: the package README (three steps now), Access & sharing, README
  settings and features, the suggested recordkeeping procedures.

Checked end to end with a built image and a real records package: the
archive imported at start, pages browsed without an account, a change
refused, and the container refusing to start once an account existed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-15 20:03:56 -05:00
1 parent 34e3232350
commit d956cfbe83
14 files changed
+229 -33

No files matched your search

+7 -6
View File
@@ -82,12 +82,13 @@ class RecordsIntegrityTest < ActionDispatch::IntegrationTest
def zip.text(name) = read(name).force_encoding("UTF-8")
assert_equal %w[README.txt logbook-entries.pdf n12345.sam.zip record-history.csv signatures.csv status-report.html viewer/docker-compose.yml], zip.entries.map(&:name).sort
readme = zip.text("README.txt")
assert_includes readme, 'docker compose logs web | grep "Setup code"'
viewer = YAML.safe_load(zip.text("viewer/docker-compose.yml"))
version = SystemInfo.new.version
assert_equal "barrettefab/simple-aircraft-manager-rails:#{version}", viewer.dig("services", "web", "image") # the release that made it
assert_equal "false", viewer.dig("services", "web", "environment", "FORCE_SSL")
assert_includes zip.text("viewer/docker-compose.yml"), 'grep "Setup code"'
assert_includes readme, "No account is needed: it's a read-only copy."
web = YAML.safe_load(zip.text("viewer/docker-compose.yml")).dig("services", "web")
assert_equal "barrettefab/simple-aircraft-manager-rails:#{SystemInfo.new.version}", web["image"] # the release that made it
assert_equal({ "SAM_VIEWER" => "true", "SAM_VIEWER_ARCHIVE" => "/import/n12345.sam.zip", "SOLID_QUEUE_SKIP_RECURRING" => "true" },
web["environment"].slice("SAM_VIEWER", "SAM_VIEWER_ARCHIVE", "SOLID_QUEUE_SKIP_RECURRING"))
assert_equal [ "127.0.0.1:3000:80" ], web["ports"] # this computer only
assert_includes web["volumes"], "../n12345.sam.zip:/import/n12345.sam.zip:ro"
assert_includes readme, "All 2 logbook entries, oldest first. 1 are signed electronically"
assert_includes readme, "Electronic records since: 2026-01-01"
assert_includes readme, "scans marked \"legacy record\""