Caretaker Express · PostgreSQL · Cedar

Module 10 · Complete, test and operate the application

10.3 From a clean checkout, and what production needs

Document how to run Caretaker, prove the instructions work on a fresh clone with its own database, and list honestly what separates this learning application from a production one.

≈ 30 min 16 steps 41 lines of code Replay verified

Starting point

The application works in your folder, with a database, .env and node_modules that grew over ten modules. That is exactly the situation in which "it works on my machine" hides missing steps.

Outcome

Text
README.md     (new: how to run, test and reset Caretaker)

A fresh clone in /tmp/caretaker-clean, with its own Docker volume, installs, migrates, seeds, passes every test and serves pages using only the commands in the README. Then a table of what production would need.

The problem

Anything that exists only on your machine is invisible to a new developer, a CI server, or you in six months: an .env value you typed once, a database you migrated by hand, a package installed globally. The only reliable test is to start from nothing.

Build it

1. A README

Create fileREADME.mdText
# Caretaker A multi-tenant building-maintenance application built with Express 5, PostgreSQL 18 and Cedar 4.14,as the project of a follow-along course. All data is synthetic. ## Requirements - Node.js 22 or 24 LTS, npm- Docker with Compose v2 (PostgreSQL runs in a container on port 5433) ## Run it     npm ci    cp .env.example .env    # then put long random values in SESSION_SECRET and AUTHZ_SERVICE_TOKEN, for example:    # node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"    docker compose up -d --wait    npm run db:migrate    npm run db:seed    npm run dev            # http://localhost:3000 Seeded users (password `password123`, local use only): alice, bob, carol, dave, nora, ravi `@example.test`. ## Commands | Command | What it does ||---|---|| `npm run dev` / `npm start` | Start the app (with or without restart on save) || `npm test` | Run every test against the `caretaker_test` database (it migrates and seeds itself) || `npm run check` | Validate the Cedar policies, then run the tests || `npm run db:migrate` / `db:seed` / `db:reset` | Apply migrations / load the scenario / drop, migrate and seed (local only) || `npm run authz:validate` | Validate `src/authz/policies/*.cedar` against `src/authz/schema.cedarschema` || `npm run authz:explain -- alice ViewIssue 101` | Show every value from database rows to Cedar's decision || `npm run authz:service` | Optional separate decision service on port 4000 | ## Authorization in one paragraph Routes load a resource, call `can(user, action, resource)`, then act. `can()` builds Cedar entitiesfrom the session's user ID and database rows (`src/authz/entities.js`, `request.js`) and evaluates themagainst the policies in `src/authz/policies` (`src/authz/cedar.js`), failing closed. Lists are filteredin SQL by `src/models/scope.js`; `test/list-parity.test.js` proves the SQL and the policies agree.
Run and comparecaretaker/
git add README.md
git commit -m "Add a README"
[main c9388d9] Add a README
 1 file changed, 41 insertions(+)
 create mode 100644 README.md

2. A clean clone with its own database

Stop your development database first, so that the clone can use port 5433. down without -v keeps your data in its volume:

Run and comparecaretaker/
docker compose down
 Container caretaker-db-1 Stopping 
 Container caretaker-db-1 Stopped 
 Container caretaker-db-1 Removing 
 Container caretaker-db-1 Removed 
 Network caretaker_default Removing 
 Network caretaker_default Removed

Clone the repository into a fresh folder. git clone copies only committed files: no .env, no node_modules, no database.

Run and comparecaretaker/
rm -rf /tmp/caretaker-clean
git clone . /tmp/caretaker-clean
Cloning into '/tmp/caretaker-clean'...
done.

From here, every command runs in the clone, as the README says. Install exactly the locked versions:

Run and compare/tmp/caretaker-clean
npm ci

added 124 packages, and audited 125 packages in 2s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Create .env and fill the two secrets with random values. This small script replaces the empty SESSION_SECRET= and AUTHZ_SERVICE_TOKEN= lines:

Run/tmp/caretaker-clean
cp .env.example .env
node -e "
const fs = require('node:fs');
const random = () => require('node:crypto').randomBytes(32).toString('hex');
const text = fs.readFileSync('.env', 'utf8').replace(/^(SESSION_SECRET|AUTHZ_SERVICE_TOKEN)=$/gm, (line, key) => key + '=' + random());
fs.writeFileSync('.env', text);
"

The clone's folder is called caretaker-clean, so Compose names its project, container and volume after that. It starts with an empty volume, and the init script creates the test database:

Run and compare/tmp/caretaker-clean
docker compose up -d --wait
 Network caretaker-clean_default Creating 
 Network caretaker-clean_default Creating 
 Volume caretaker-clean_pgdata Creating 
 Volume caretaker-clean_pgdata Creating 
 Volume caretaker-clean_pgdata Created 
 Volume caretaker-clean_pgdata Created 
 Network caretaker-clean_default Created 
 Network caretaker-clean_default Created 
 Container caretaker-clean-db-1 Creating 
 Container caretaker-clean-db-1 Created 
 Container caretaker-clean-db-1 Starting 
 Container caretaker-clean-db-1 Started 
 Container caretaker-clean-db-1 Waiting 
 Container caretaker-clean-db-1 Healthy
Run and compare/tmp/caretaker-clean
npm run db:migrate

> caretaker@1.0.0 db:migrate
> node --env-file=.env scripts/migrate.js

applied 001_create_organisations_buildings_issues.sql
applied 002_create_inspections.sql
applied 003_create_users.sql
applied 004_create_session_table.sql
applied 005_create_memberships_and_building_roles.sql
applied 006_create_permission_changes.sql
migrations are up to date
Run and compare/tmp/caretaker-clean
npm run db:seed

> caretaker@1.0.0 db:seed
> node --env-file=.env scripts/seed.js

seeded the Caretaker scenario
Run and compare/tmp/caretaker-clean
npm run check

> caretaker@1.0.0 check
> npm run authz:validate && npm test


> caretaker@1.0.0 authz:validate
> node scripts/validate-policies.js

12 policies are valid against the schema

> caretaker@1.0.0 test
> node --env-file=.env.test --test --test-concurrency=1 --test-reporter=spec "test/**/*.test.js"

✔ view issue 101 (building 10) (506.265834ms)
✔ edit issue 101 (22.322209ms)
✔ view issue 103 (building 20) (24.083875ms)
✔ edit issue 103 (reported by dave) (22.929833ms)
✔ report an issue at building 20 (27.510084ms)
✔ view issue 105 (building 30) (17.713459ms)
✔ view issue 106 (building 40, reported by bob) (18.209292ms)
✔ approve inspection 201 (created by dave) (17.330292ms)
✔ approve inspection 202 (created by alice) (19.475333ms)
✔ update organisation 1 (20.134875ms)
✔ change own role at building 10 (5.11275ms)
✔ grant building_admin at building 10 to dave (29.963625ms)
✔ grant viewer at building 10 to dave (16.556666ms)
✔ issues in each user's list come only from the expected buildings (124.990292ms)
✔ the scenario loads exactly as specified (212.401583ms)
✔ only one active assignment per user, building and role (0.897084ms)
✔ a revoked role can be granted again (1.251541ms)
✔ the My access page shows what the server loaded (71.704792ms)
✔ a correct login creates a session and shows the user (278.616583ms)
✔ a wrong password or unknown email gets the same 401 (55.647292ms)
✔ registration validates, creates a user, and logs them in (38.800875ms)
✔ registering an existing email is a field error (30.735917ms)
✔ logout destroys the session (51.924834ms)
✔ allow: a permit matched and nothing forbade it (214.993458ms)
✔ explicit deny: a forbid overrides a matching permit (3.063333ms)
✔ implicit deny: no permit matched (2.289333ms)
authz problem {
Show 121 more lines user: 1, action: 'ApproveInspection', resource: 'Inspection::201', decision: 'failure', errors: [ 'entity does not conform to the schema: in attribute `status` on `Caretaker::Inspection::"201"`, type mismatch: value was expected to have type string, but it actually has type long: `7`' ] } ✔ failure: a row that does not fit the schema is never allowed (3.586334ms) ✔ unknown actions throw instead of deciding (1.860625ms) ✔ unknown callers are refused (213.345667ms) ✔ decisions match the app (25.421792ms) ✔ attributes sent by the caller are ignored (2.98575ms) ✔ context is validated and used (9.739166ms) ✔ revoking dave's inspector role at building 10 takes effect on his next request (383.497541ms) ✔ a revoked assignment cannot be revoked again (4.4235ms) ✔ an assignment id from another building is not found here (4.159834ms) ✔ alice cannot revoke her own building_admin role; carol can (12.182375ms) ✔ grants are limited to members of the building's organisation (6.204375ms) ✔ a building can be created inside an organisation (292.530625ms) ✔ a duplicate building name in the same organisation is a field error (5.263708ms) ✔ the same building name is allowed in another organisation (9.347583ms) ✔ a building with issues cannot be deleted (14.453667ms) ✔ an empty building can be deleted (10.427625ms) ✔ an organisation with buildings cannot be deleted, an empty one can (24.576375ms) ✔ a logged-in POST without a token is refused with 403 (257.966083ms) ✔ a token from another session is refused (39.568083ms) ✔ the right token in the form field works (20.344208ms) ✔ every POST form on every page carries the token (52.97575ms) ✔ the dashboard counts match the database (284.487334ms) ✔ only the buildings carol can see appear (4.753375ms) ✔ headers that claim another identity are ignored (279.224416ms) ✔ query strings and form fields that claim roles are ignored (11.542791ms) ✔ a forged reporter or status in an edit form does not reach the database (5.732542ms) ✔ a forged grant context cannot make dave a building admin (5.013875ms) ✔ responses carry security headers and a request id, and no framework banner (211.959042ms) ✔ error pages show the request id as a reference (67.646833ms) ✔ unsafe production settings are reported (0.336792ms) ✔ create a draft, edit it, submit it, approve it (347.648875ms) ✔ invalid transitions are refused with 409 and change nothing (14.278209ms) ✔ only drafts can be edited (6.188209ms) ✔ returning a submitted inspection makes it editable again (9.716541ms) ✔ concurrent approvals: exactly one wins (25.415042ms) ✔ unknown actions are 404 (3.137959ms) ✔ the issues list contains only issues from visible buildings (584.529041ms) ✔ a filter for another tenant's building returns nothing (3.9835ms) ✔ the inspections list is scoped too (9.948959ms) ✔ organisations are listed for their members only (9.008666ms) ✔ the dashboard counts only visible data (10.640291ms) ✔ view issue 101 (building 10) (484.006459ms) ✔ open the edit form for issue 101 (26.695083ms) ✔ open the edit form for issue 103 (reported by dave, building 20) (24.796834ms) ✔ view issue 105 (building 30) and 106 (building 40) (40.737833ms) ✔ report an issue at building 20 (25.921167ms) ✔ a reporter cannot edit their own issue once it is closed (8.176208ms) ✔ only building admins may delete; refusals change nothing (18.470541ms) ✔ the edit form cannot move an issue to another building (4.267833ms) ✔ the list pages 10 at a time and reports the total (285.362542ms) ✔ pages do not overlap (22.920875ms) ✔ filters combine with AND (6.917625ms) ✔ sorting by priority puts critical first when descending (7.259583ms) ✔ unknown sort keys and SQL in the query string are ignored (39.9295ms) ✔ alice may update 101 at building 10 but may not create at building 20, so she cannot move it there (346.3265ms) ✔ dave may update his own issue 103 but is not a reporter at building 10 (9.252833ms) ✔ dave cannot move issue 101: he may not update it where it is (4.774542ms) ✔ carol moves 101 to building 20, but never to another organisation (11.897625ms) ✔ a forged building id on create is refused and creates nothing (25.763292ms) ✔ GET /issues lists issues from the database (287.359ms) ✔ GET /issues/101 shows one issue with its building (7.045291ms) ✔ GET /issues/:id answers 404 for unknown or malformed ids (13.716ms) ✔ POST /issues re-renders the form with errors (4.896125ms) ✔ POST /issues stores the issue and redirects to it (8.562792ms) ✔ POST /issues with a building that does not exist is a form error, not a 500 (4.407834ms) ✔ the stored row has the cleaned values and ignores a client-sent status (4.631958ms) ✔ an issue time in the future is rejected (4.307209ms) ✔ GET /issues/101/edit shows the current values (5.242292ms) ✔ POST /issues/:id/edit changes the status and updated_at (5.4295ms) ✔ POST /issues/:id/delete removes the issue (11.472833ms) ✔ the issues list contains exactly the issues Cedar lets each user view (320.05975ms) ✔ the inspections list contains exactly the inspections Cedar lets each user view (18.997917ms) ✔ only organisation admins can open the members page (422.445875ms) ✔ controlled onboarding: carol adds nora; nora sees the organisation but no building (18.476542ms) ✔ promoting dave to org_admin gives him the organisation's admin rights on his next request (12.604417ms) ✔ nobody changes their own membership (3.959833ms) ✔ unknown emails and roles are form errors (9.016875ms) ✔ a member cannot add members, even with a well-formed request (4.474916ms) ✔ GET /organisations lists organisations with building counts (277.006541ms) ✔ GET /organisations/1 shows its buildings, not other organisations' buildings (14.552125ms) ✔ POST /organisations validates and creates (14.130875ms) ✔ POST /organisations/:id/edit renames the organisation (11.549583ms) ✔ unknown organisations are 404 (5.959791ms) ✔ every policy is valid against the schema (31.881792ms) ✔ every action used by the app is mentioned by a policy, directly or through its group (9.742625ms) ✔ failed logins are limited per client; the limit then blocks even correct passwords (352.070667ms) ✔ anonymous requests are redirected to the login page (211.456833ms) ✔ anonymous writes are refused and change nothing (10.216834ms) ✔ login and register pages stay public (5.722667ms) ✔ login issues a new session id (no session fixation) (31.180208ms) ✔ returnTo only follows local paths (28.658166ms) ✔ new issues and transitions record the logged-in user (78.806709ms) ✔ the session cookie has the attributes we chose (25.263542ms) ✔ organisation 1: view and update (507.426666ms) ✔ ravi is still a member of organisation 2 but can see none of its buildings (8.117708ms) ✔ building 10: view, update, delete (53.744791ms) ✔ creating buildings needs org_admin (15.578125ms) ✔ creating an organisation makes the creator its admin (9.108042ms) ✔ inspections: view 201, open the edit form for draft 203 (39.452542ms) ✔ approve inspection 201 (dave's): only building admins (16.494375ms) ✔ creating an inspection needs inspector or building_admin at the chosen building (11.579708ms) ✔ bob gets 404 for every Liffey route, and nothing changes (444.686584ms) ✔ ravi gets 404 for every Liffey route, and nothing changes (98.234375ms) ✔ nora gets 404 for every Liffey route, and nothing changes (92.131125ms) ✔ inside one tenant: alice, a viewer at building 20, cannot change anything there (64.662792ms) ℹ tests 131 ℹ suites 0 ℹ pass 131 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 14477.947

All six migrations applied in order, the policies validated, and the 131 tests passed on a machine state that did not exist a minute ago.

Run and inspect

Start the clone's server and use it:

Server terminal (leave it running)caretaker/
npm start
> caretaker@1.0.0 start
> node --env-file=.env src/server.js

Caretaker listening on http://localhost:3000
Run and compare/tmp/caretaker-clean
rm -f /tmp/clean-alice.txt
TOKEN=$(curl -s -c /tmp/clean-alice.txt http://localhost:3000/login | sed -n 's/.*name="csrf-token" content="\([^"]*\)".*/\1/p')
curl -s -b /tmp/clean-alice.txt -c /tmp/clean-alice.txt -o /dev/null http://localhost:3000/login -d _csrf=$TOKEN -d email=alice@example.test -d password=password123
curl -s -b /tmp/clean-alice.txt http://localhost:3000/issues/101 | grep "<h1>"
  <h1>Lift stuck between floors 2 and 3</h1>
Ctrl+C Stop the server in the server terminal.

Remove the clone's container and volume, and bring your own database back:

Run and compare/tmp/caretaker-clean
docker compose down -v
 Container caretaker-clean-db-1 Stopping 
 Container caretaker-clean-db-1 Stopped 
 Container caretaker-clean-db-1 Removing 
 Container caretaker-clean-db-1 Removed 
 Volume caretaker-clean_pgdata Removing 
 Network caretaker-clean_default Removing 
 Volume caretaker-clean_pgdata Removed 
 Network caretaker-clean_default Removed
Run and comparecaretaker/
docker compose up -d --wait
 Network caretaker_default Creating 
 Network caretaker_default Creating 
 Network caretaker_default Created 
 Network caretaker_default Created 
 Container caretaker-db-1 Creating 
 Container caretaker-db-1 Created 
 Container caretaker-db-1 Starting 
 Container caretaker-db-1 Started 
 Container caretaker-db-1 Waiting 
 Container caretaker-db-1 Healthy

Experiment

Predict If you had forgotten to commit migrations/006_create_permission_changes.sql, at which step of the clean run would you have noticed, and how?
Reveal Answer

At npm run db:migrate the output would end at 005, and the next step that touches the table fails: the seed truncates tables that reference users, the members and building-access tests fail with relation "permission_changes" does not exist, and npm run check reports them. Your own folder would never have shown the problem, because the file existed there. This is why a clean-checkout run, by hand or in CI, belongs in every project.

Checkpoint

Back in your project, with your own database:

Run and comparecaretaker/
npm test

> caretaker@1.0.0 test
> node --env-file=.env.test --test --test-concurrency=1 --test-reporter=spec "test/**/*.test.js"

✔ view issue 101 (building 10) (499.404916ms)
✔ edit issue 101 (25.31ms)
✔ view issue 103 (building 20) (24.322542ms)
✔ edit issue 103 (reported by dave) (25.156542ms)
✔ report an issue at building 20 (25.574042ms)
✔ view issue 105 (building 30) (19.621708ms)
✔ view issue 106 (building 40, reported by bob) (17.604792ms)
✔ approve inspection 201 (created by dave) (16.585125ms)
✔ approve inspection 202 (created by alice) (20.73975ms)
✔ update organisation 1 (18.12775ms)
✔ change own role at building 10 (6.813959ms)
✔ grant building_admin at building 10 to dave (19.873208ms)
✔ grant viewer at building 10 to dave (16.785375ms)
✔ issues in each user's list come only from the expected buildings (125.957875ms)
✔ the scenario loads exactly as specified (198.432959ms)
✔ only one active assignment per user, building and role (0.854208ms)
✔ a revoked role can be granted again (1.1855ms)
✔ the My access page shows what the server loaded (74.26625ms)
✔ a correct login creates a session and shows the user (309.312083ms)
✔ a wrong password or unknown email gets the same 401 (57.250875ms)
✔ registration validates, creates a user, and logs them in (53.056334ms)
✔ registering an existing email is a field error (30.771916ms)
✔ logout destroys the session (55.228167ms)
✔ allow: a permit matched and nothing forbade it (210.615917ms)
✔ explicit deny: a forbid overrides a matching permit (3.222667ms)
✔ implicit deny: no permit matched (2.591083ms)
authz problem {
  user: 1,
  action: 'ApproveInspection',
  resource: 'Inspection::201',
  decision: 'failure',
  errors: [
    'entity does not conform to the schema: in attribute `status` on `Caretaker::Inspection::"201"`, type mismatch: value was expected to have type string, but it actually has type long: `7`'
  ]
}
✔ failure: a row that does not fit the schema is never allowed (3.536625ms)
Show 112 more lines✔ unknown actions throw instead of deciding (1.625958ms) ✔ unknown callers are refused (201.044292ms) ✔ decisions match the app (25.532583ms) ✔ attributes sent by the caller are ignored (2.914125ms) ✔ context is validated and used (9.650791ms) ✔ revoking dave's inspector role at building 10 takes effect on his next request (382.434417ms) ✔ a revoked assignment cannot be revoked again (4.829042ms) ✔ an assignment id from another building is not found here (6.614833ms) ✔ alice cannot revoke her own building_admin role; carol can (12.756834ms) ✔ grants are limited to members of the building's organisation (6.334334ms) ✔ a building can be created inside an organisation (290.43075ms) ✔ a duplicate building name in the same organisation is a field error (6.617542ms) ✔ the same building name is allowed in another organisation (10.489292ms) ✔ a building with issues cannot be deleted (15.288875ms) ✔ an empty building can be deleted (10.537417ms) ✔ an organisation with buildings cannot be deleted, an empty one can (24.336292ms) ✔ a logged-in POST without a token is refused with 403 (276.827667ms) ✔ a token from another session is refused (37.651458ms) ✔ the right token in the form field works (19.657416ms) ✔ every POST form on every page carries the token (57.735125ms) ✔ the dashboard counts match the database (271.802917ms) ✔ only the buildings carol can see appear (6.250041ms) ✔ headers that claim another identity are ignored (269.42825ms) ✔ query strings and form fields that claim roles are ignored (11.814625ms) ✔ a forged reporter or status in an edit form does not reach the database (5.810375ms) ✔ a forged grant context cannot make dave a building admin (5.355375ms) ✔ responses carry security headers and a request id, and no framework banner (197.547125ms) ✔ error pages show the request id as a reference (63.878667ms) ✔ unsafe production settings are reported (0.354334ms) ✔ create a draft, edit it, submit it, approve it (341.295042ms) ✔ invalid transitions are refused with 409 and change nothing (12.239666ms) ✔ only drafts can be edited (5.887ms) ✔ returning a submitted inspection makes it editable again (8.677167ms) ✔ concurrent approvals: exactly one wins (26.864916ms) ✔ unknown actions are 404 (2.994417ms) ✔ the issues list contains only issues from visible buildings (571.076875ms) ✔ a filter for another tenant's building returns nothing (3.921375ms) ✔ the inspections list is scoped too (9.656709ms) ✔ organisations are listed for their members only (8.0555ms) ✔ the dashboard counts only visible data (6.588375ms) ✔ view issue 101 (building 10) (468.91625ms) ✔ open the edit form for issue 101 (25.696708ms) ✔ open the edit form for issue 103 (reported by dave, building 20) (26.262375ms) ✔ view issue 105 (building 30) and 106 (building 40) (50.396042ms) ✔ report an issue at building 20 (25.715416ms) ✔ a reporter cannot edit their own issue once it is closed (8.291458ms) ✔ only building admins may delete; refusals change nothing (15.195375ms) ✔ the edit form cannot move an issue to another building (4.094709ms) ✔ the list pages 10 at a time and reports the total (306.293875ms) ✔ pages do not overlap (23.448875ms) ✔ filters combine with AND (6.814167ms) ✔ sorting by priority puts critical first when descending (7.635083ms) ✔ unknown sort keys and SQL in the query string are ignored (41.480042ms) ✔ alice may update 101 at building 10 but may not create at building 20, so she cannot move it there (351.989ms) ✔ dave may update his own issue 103 but is not a reporter at building 10 (6.202542ms) ✔ dave cannot move issue 101: he may not update it where it is (4.728792ms) ✔ carol moves 101 to building 20, but never to another organisation (10.3435ms) ✔ a forged building id on create is refused and creates nothing (23.198959ms) ✔ GET /issues lists issues from the database (274.433458ms) ✔ GET /issues/101 shows one issue with its building (7.018708ms) ✔ GET /issues/:id answers 404 for unknown or malformed ids (13.8235ms) ✔ POST /issues re-renders the form with errors (5.184667ms) ✔ POST /issues stores the issue and redirects to it (8.337ms) ✔ POST /issues with a building that does not exist is a form error, not a 500 (4.6735ms) ✔ the stored row has the cleaned values and ignores a client-sent status (4.835917ms) ✔ an issue time in the future is rejected (4.196625ms) ✔ GET /issues/101/edit shows the current values (5.136042ms) ✔ POST /issues/:id/edit changes the status and updated_at (5.260917ms) ✔ POST /issues/:id/delete removes the issue (11.322667ms) ✔ the issues list contains exactly the issues Cedar lets each user view (333.807ms) ✔ the inspections list contains exactly the inspections Cedar lets each user view (20.6405ms) ✔ only organisation admins can open the members page (427.333167ms) ✔ controlled onboarding: carol adds nora; nora sees the organisation but no building (16.074333ms) ✔ promoting dave to org_admin gives him the organisation's admin rights on his next request (12.10775ms) ✔ nobody changes their own membership (3.806458ms) ✔ unknown emails and roles are form errors (9.003125ms) ✔ a member cannot add members, even with a well-formed request (3.445708ms) ✔ GET /organisations lists organisations with building counts (255.758167ms) ✔ GET /organisations/1 shows its buildings, not other organisations' buildings (14.661375ms) ✔ POST /organisations validates and creates (14.459041ms) ✔ POST /organisations/:id/edit renames the organisation (11.291292ms) ✔ unknown organisations are 404 (6.41625ms) ✔ every policy is valid against the schema (31.900792ms) ✔ every action used by the app is mentioned by a policy, directly or through its group (9.285709ms) ✔ failed logins are limited per client; the limit then blocks even correct passwords (342.606916ms) ✔ anonymous requests are redirected to the login page (221.757458ms) ✔ anonymous writes are refused and change nothing (10.547709ms) ✔ login and register pages stay public (5.78475ms) ✔ login issues a new session id (no session fixation) (31.481084ms) ✔ returnTo only follows local paths (28.070167ms) ✔ new issues and transitions record the logged-in user (87.5265ms) ✔ the session cookie has the attributes we chose (28.965584ms) ✔ organisation 1: view and update (483.329833ms) ✔ ravi is still a member of organisation 2 but can see none of its buildings (7.77975ms) ✔ building 10: view, update, delete (54.852916ms) ✔ creating buildings needs org_admin (14.796167ms) ✔ creating an organisation makes the creator its admin (11.835583ms) ✔ inspections: view 201, open the edit form for draft 203 (42.515125ms) ✔ approve inspection 201 (dave's): only building admins (21.20675ms) ✔ creating an inspection needs inspector or building_admin at the chosen building (12.600875ms) ✔ bob gets 404 for every Liffey route, and nothing changes (481.156333ms) ✔ ravi gets 404 for every Liffey route, and nothing changes (117.660584ms) ✔ nora gets 404 for every Liffey route, and nothing changes (92.964ms) ✔ inside one tenant: alice, a viewer at building 20, cannot change anything there (70.1975ms) ℹ tests 131 ℹ suites 0 ℹ pass 131 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 14781.763458

What production would need

Caretaker is learning-grade. Its authorization design is sound, and much of the code would survive, but a production deployment needs more:

Area In this course In production
Database credentials The image's superuser, owner of every table A migration user that owns the schema, an app user with minimal grants (lesson 9.3), optionally row-level security
Secrets .env on disk A secret manager; rotation for the session secret and service tokens
Transport http://localhost HTTPS everywhere, COOKIE_SECURE=1, TRUST_PROXY=1 behind a proxy, HSTS
Accounts Register, log in, log out Email verification, password reset, MFA, sessions invalidated on password change, account deactivation
Abuse limits In-memory login limiter per process Shared limiter store, per-account limits, monitoring
Policies Files in Git, validated in tests The same, plus required review for any change under src/authz, and the access matrix in CI
Observability Console logs, request IDs Structured logs shipped and retained; alerts on authz problem and list/policy mismatch
Data Docker volume Backups, restore drills, retention rules for maintenance records and the permission log
Dependencies Pinned and locked Automated update checks, npm audit, and re-running the access matrix on every Cedar upgrade
Scale One process, per-request access loading Several processes (sessions already in PostgreSQL), connection limits, measured authorization latency

Recap and next step

The README describes the project, and a fresh clone with an empty database reached 131 passing tests and a working page using only those instructions. The table lists the work between this learning application and a production service, with Cedar's part of it largely done.

The last lesson recaps the whole course in one request, and sets you a feature to build on your own.