Skip to content

List movements through the app API - #926

Merged
rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt
Nov 20, 2026
Merged

rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt

Conversation

@rzueger

@rzueger rzueger commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

A pilot in Claude should be able to ask "what did I fly this week". The Open Digital MCP hub calls a new read route of
the movement API for that. The route returns what the app shows the caller:

  • pilots get their own movements;
  • admins and allMovements operators get all of them;
  • movements of others come without personal data.

Reading needs a token scope of its own, movements:read, which the login now issues (odch/odch-login dc5ddc6).
Writing still needs movements:write.

Commits

  1. Check the scope of central login tokens per route.
    • The verifier accepts movements:write and/or movements:read and returns the movement scopes.
    • The login actor carries them, and the new requireScope middleware checks the scope a route needs. Without it
      the answer is 403 with reason insufficient-scope.
    • Firebase actors carry no scopes: the app may do what its user may.
  2. List movements through the app API. GET /app/movements?from=<ISO>&to=<ISO>[&type=departure|arrival], also
    under /api. At most 31 days and 200 movements per type; truncated is set when there are more.
    • domain/readView.js: own movements come with all fields. Movements of others only carry a whitelist of
      operational fields: aircraft, time, location, route, runway, counts, fees, payment method and status. The
      whitelist leaves out the name, e-mail, phone, member number, remarks, route text, customs form and invoice
      recipient, and any field added to movements later.
    • Rights of a central login caller: those of the app's Firebase user with the same verified e-mail. The app
      signs pilots in by e-mail code, with one user per address. That means /admins/<uid> or
      /logins/<uid>/allMovements, the same check as the client's canSeeAllMovements and the rules. This applies
      only to reading; for writes such callers are still never admins.
    • Read as the caller through the REST API (auth_variable_override), like the writes. For an "all" read the
      request runs as the app user, so the read rules see the same uid as in the app. The rules remain the second line
      of defence: a pilot can only query the own createdBy_orderKey range.
    • application/listMovements.js: the use case. It checks the period and ownership a second time.
    • Docs in projects/Configuration.md (centralLogin).

Unchanged

  • The app, which keeps reading the database directly.
  • The database rules.
  • Writes by the app and by the hub. The write routes now check movements:write, which every hub token so far
    carries.

Test plan

  • readView.spec.js: own movements with all fields; for others only operational fields, with no personal value
    anywhere in the JSON.
  • listMovements.spec.js:
    • own vs all;
    • sorting;
    • defensive filtering;
    • truncation;
    • a guest without e-mail gets nothing.
  • rtdbMovementRepository.spec.js:
    • reader rights for admin, operator, pilot, a login caller mapped by e-mail, unverified or disabled or missing app
      users, shared access;
    • the exact REST queries.
  • databaseRest.spec.js: read with JSON-encoded parameters, rules denial and other failures.
  • movementRoutes.spec.js:
    • the list and its validation errors;
    • 401 without a token;
    • 500 on a rules disagreement;
    • read-only tokens cannot write, write-only tokens cannot list.
  • appAuth.spec.js and loginTokens.spec.js: the scopes.
  • npm test: 356 suites / 7902 tests
  • npm run typecheck
  • npm run test:functions: 111 suites / 4668 tests
  • npm run test:rules (database emulator), with the new movementApiRead.rules.js against the built lsze rules:
    • pilots, also with a login token, get only their own movements;
    • admins and operators get all, without personal data;
    • a login caller gets the app user's rights;
    • the rules deny an unbounded query and another pilot's index.
    • The existing parity and write assertions are unchanged.
  • End to end, locally (odch/mcp-hub e2e/run.sh, 19/19): real login, real hub and the real routes of this
    branch. A pilot in a Claude-like client lists the day: their own movements only, not those of another pilot.
  • After merge: list in Claude as a pilot and as an admin of lsze test (after reconnecting the connector)

Generated by Claude Code

Tokens of the central login carried movements:write, which every app
API route required. The login now also issues movements:read, to list
movements. The verifier accepts either and returns the movement
scopes; the login actor carries them, and the new requireScope
middleware checks the one a route needs (403 insufficient-scope).
Firebase actors carry no scopes: the app may do what its user may.
GET /app/movements?from=&to=[&type=] (also under /api) returns the
movements of a period (at most 31 days, 200 per type) as the app shows
them to the caller, for API clients such as the Open Digital MCP hub;
the app keeps reading the database directly. Tokens of the central
login need movements:read; the write routes now need movements:write.

- the caller's own movements with all fields; for admins and
  allMovements operators (or shared access) all of them, others'
  without personal data (domain/readView.js: an operational field
  whitelist, no name, e-mail, phone, member number, remarks, route
  text, customs form or invoice recipient)
- a caller of the central login has the rights of the app's Firebase
  user with the same verified e-mail (one user per address); never
  for writes
- read as the caller through the REST API (auth_variable_override;
  for an all read as the app user), so the read rules still apply:
  an emulator test (test/rules/movementApiRead.rules.js, part of
  test:rules) shows pilots get only their own and the rules deny an
  unbounded query or another pilot's index
@rzueger
rzueger merged commit e1d0f92 into develop Nov 20, 2026
2 checks passed
@rzueger
rzueger deleted the claude/magical-dirac-ww38gt branch November 20, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants