Repository navigation
Conversation
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
… on the user; chat messages honour it
…ction per device; dead tokens are retired
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.
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.
fleetbase.api-or-platform:fleetbase.apithat also accepts the platform token (flb_platform_…).AuthenticateApiOrPlatformTokenchecks a platform-shaped bearer token against the platform token (401 if wrong, never tried as an API key) and hands every other credential toAuthenticateOnceWithBasicAuthunchanged.PlatformApi::authenticated($request)tells a controller which kind it is handling. New helpers:isPlatformToken(),markAuthenticated(),TOKEN_PREFIX.PlatformApi::markUsed()writeslast_used_atat most once every five minutes. It wrote on every request, and each write clears the system settings cache.fleetbase.platform-apiandfleetbase.apiare 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,MiddlewareContractsTestandCoreProviderContractsTestpass locally with new tests for the middleware, the usage write limit, per-address buckets and the provider group.pestrun ran out of memory part-way, so CI is the first full run.v1routes.