Repository navigation
List movements through the app API - #926
Merged
Merged
Conversation
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
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Reading needs a token scope of its own,
movements:read, which the login now issues (odch/odch-logindc5ddc6).Writing still needs
movements:write.Commits
movements:writeand/ormovements:readand returns the movement scopes.requireScopemiddleware checks the scope a route needs. Without itthe answer is 403 with reason
insufficient-scope.GET /app/movements?from=<ISO>&to=<ISO>[&type=departure|arrival], alsounder
/api. At most 31 days and 200 movements per type;truncatedis set when there are more.domain/readView.js: own movements come with all fields. Movements of others only carry a whitelist ofoperational 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.
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'scanSeeAllMovementsand the rules. This appliesonly to reading; for writes such callers are still never admins.
auth_variable_override), like the writes. For an "all" read therequest 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_orderKeyrange.application/listMovements.js: the use case. It checks the period and ownership a second time.projects/Configuration.md(centralLogin).Unchanged
movements:write, which every hub token so farcarries.
Test plan
readView.spec.js: own movements with all fields; for others only operational fields, with no personal valueanywhere in the JSON.
listMovements.spec.js:rtdbMovementRepository.spec.js:users, shared access;
databaseRest.spec.js:readwith JSON-encoded parameters, rules denial and other failures.movementRoutes.spec.js:appAuth.spec.jsandloginTokens.spec.js: the scopes.npm test: 356 suites / 7902 testsnpm run typechecknpm run test:functions: 111 suites / 4668 testsnpm run test:rules(database emulator), with the newmovementApiRead.rules.jsagainst the built lsze rules:e2e/run.sh, 19/19): real login, real hub and the real routes of thisbranch. A pilot in a Claude-like client lists the day: their own movements only, not those of another pilot.
Generated by Claude Code