Repository navigation
Accept central login tokens in the app API where configured - #923
Merged
Merged
Conversation
The MCP hub (odch/mcp-hub) records movements for a pilot. It exchanges
the pilot's token at the central login (odch/odch-login, RFC 8693) for
a short-lived token for exactly one Flightbox instance and calls the
movement routes of the app API with it.
- functions/api/http/loginTokens.js verifies such tokens: ES256 JWT
(typ at+jwt) from the configured issuer, audience of this instance,
verified e-mail, scope movements:write, keys from the login's JWKS
(cached, refetched for an unknown kid).
- appAuth takes them only when a verifier is passed: tokens whose iss
is the login go there, all others to Firebase as before. The actor
is the pilot with the token's e-mail, uid "login:<account id>",
never admin, guest or kiosk. Ownership and the database rules
(auth.token.email via auth_variable_override) apply unchanged.
- New project setting centralLogin {issuer, jwksUri, audience}, per
environment, validated by generateServerConfig.js. Not set for any
project yet: the login runs at a run.app address for now.
- jsonwebtoken (already in the tree through firebase-admin) becomes a
direct dependency; jose is ESM-only and does not load under Jest.
Sets centralLogin for lsze test to the dev login (odch-login-dev, europe-west1), so the MCP hub (odch-mcp-hub-dev) can record movements there for a pilot. Only the functions of lsze-test read it.
This was referenced Nov 20, 2026
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
Small follow-up to #922 for the proof of concept "central login + MCP hub". The Open Digital MCP hub
(
odch/mcp-hub) records departures and arrivals for a pilot from an AI client (Claude). It exchanges thepilot's token at the central login (
odch/odch-login, token exchange RFC 8693) for a 5-minute token forexactly one Flightbox instance and calls the movement routes of #922 with it. This PR lets
functions/api/http/appAuth.jsaccept those tokens, only where the project config setscentralLogin,and sets it for lsze test only, pointing to the dev login that now runs in
odch-login-dev.Commits
Accept central login tokens in the app API where configured
functions/api/http/loginTokens.js(new): verifies login tokens. ES256 JWT withtypat+jwt,iss=the configured issuer,
aud= this instance (e.g.flightbox-lsze-test), verified e-mail(
email,email_verified), scopemovements:write, lifetime at most 1 h. Keys come from the login'sJWKS, cached 10 min, refetched for an unknown
kid(at most every 30 s); a failing refetch keeps thecached keys.
appAuth: with a verifier, tokens whose (unverified)issis the login go to it; all others go toFirebase as before. The actor is the pilot with the token's e-mail (lower-cased), uid
login:<account id>, never admin, guest or kiosk. A rejected token is 401 (Invalid or expired token),unreachable keys are 500, as for Firebase tokens.
registerMovementRoutesbuilds the verifier fromconfig.centralLogin.centralLogin: {issuer, jwksUri, audience}per environment, validated bytasks/generateServerConfig.js(dependency-freecentralLoginConfig.js, so the deploy can load it beforethe functions'
npm ci). Only in the generated config when set. Documented inprojects/Configuration.md.jsonwebtokenbecomes a direct dependency offunctions/(it is already in the tree throughfirebase-admin; the lockfile only gains the entry).josewould be the usual choice, but it is ESM-onlyand does not load under Jest.
Accept central login tokens on lsze test:
projects/lsze.json,environments.test:A spec checks that no other project or environment sets it.
Ownership is unchanged: the domain sets
createdByto the actor's e-mail and the REST adapter writes withauth_variable_override{uid: "login:…", token: {email}}, so the database rules checkauth.token.emailexactly as for a pilot signed in to the app with the same address. The pilot sees and edits the same
movements either way.
Unchanged
Test plan
npm test: 353 suites / 7794 testsnpm run typechecknpm run test:functions: 108 suites / 4561 tests. New:loginTokens.spec.js(algorithm confusion,alg: none, wrong type, audience, issuer, expiry, lifetime, unknown/rotated keys, foreign signature,missing e-mail/scope, JWKS outage, stale cache),
appAuth(actor, 401, 500, Firebase still works,never admin even with an
/adminsentry), movement routes with real tokens (create owned by the pilot,update own, 403 for another pilot's movement, 401 for other instance/scope, 401 without config),
generateServerConfig(emitted only where set, lsze test only, malformed configs rejected).against the database emulator with the built lsze rules, behind the real login and hub; a Claude-like
MCP client (dynamic registration, PKCE, e-mail code, passkey in Chromium) recorded a departure and an
arrival (
createdBy= pilot's address), patched its arrival, got 403 for another pilot's movement; thehub's own token was rejected (401). Harness:
odch/mcp-hube2e/.odch-login-dev) and serves its metadata and JWKS.e-mail address.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EsQwcnrmAeK6sEnrzrGVr4