Skip to content

Release v2.0.6: Platform token sign-in for instance apps - #346

Open
roncodes wants to merge 6 commits into
mainfrom
release/v2.0.6
Open

roncodes wants to merge 6 commits into
mainfrom
release/v2.0.6

Conversation

@roncodes

@roncodes roncodes commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What changed

An app built for a whole instance, such as Navigator, has no organization until its user signs in, so it had to carry one organization's API key just to reach the sign-in routes. This adds a way for those routes to accept the instance's platform token instead.

  • New middleware group fleetbase.api-or-platform: fleetbase.api that also accepts the platform token (flb_platform_…). AuthenticateApiOrPlatformToken checks a platform-shaped bearer token against the platform token (401 if wrong, never tried as an API key) and hands every other credential to AuthenticateOnceWithBasicAuth unchanged.
  • A request that used the token has no organization and no user. PlatformApi::authenticated($request) tells a controller which kind it is handling. New helpers: isPlatformToken(), markAuthenticated(), TOKEN_PREFIX.
  • Rate limiting: requests carrying the platform token are bucketed per client address. The limiter keys on the credential, and every installed app presents the same token, so they all shared one bucket.
  • PlatformApi::markUsed() writes last_used_at at most once every five minutes. It wrote on every request, and each write clears the system settings cache.

fleetbase.platform-api and fleetbase.api are unchanged. No migration.

The platform token ships inside apps, so it is public: only routes that are safe for anyone to call belong in the new group. Fleet-Ops v0.7.4 puts the driver sign-in routes in it.

Testing

  • PlatformApiTest, MiddlewareContractsTest and CoreProviderContractsTest pass locally with new tests for the middleware, the usage write limit, per-address buckets and the provider group.
  • A full local pest run ran out of memory part-way, so CI is the first full run.
  • Checked against a local instance: a wrong platform token is refused on a sign-in route, a valid one reaches it, and a valid one is refused on ordinary v1 routes.

Adds the fleetbase.api-or-platform middleware group: fleetbase.api that also
accepts the instance's platform token, for routes an app calls before its
user signs in. A request that used the token has no organization and no
user; PlatformApi::authenticated() tells a controller which it is handling.

Requests carrying the platform token are rate limited per client address,
since every installed app presents the same token, and a use of the token
is written down at most once every five minutes.
The token is stored encrypted next to its hash when it is rotated, and PlatformApi::token() returns it while it is the one in force. FleetOps uses it to build the Navigator link and QR code, so linking no longer hands an organization's API key to the app. A token rotated before this change is not retrievable until it is rotated again; status() reports which.
…ts, list feeds are capped

- A user finds, posts to, reads and changes only channels they take part in; renaming and deleting a channel is for its creator; removing someone else is for the creator, leaving is for anyone
- A message is sent and marked read only as the caller's own participant in that channel, and deleted only by its author
- Posting into a chat closed with its order is refused
- Participants named on create must belong to the caller's company
- The list call returns each channel's latest 30 feed entries with feed_truncated; the find call takes limit and before to page older messages
- Requests made with the organization's own key keep their wider reach
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.

1 participant