Authentication for fleet should happen in several places:
Both the ship and the bridge should check Authorization: headers.
Outside to Bridge
All communications to the bridge should include a bearer token that identifies itself as a session to a specific user. Store users and sessions in a managed bun:sqlite database (abstract this into a Database class that manages and validates).
Users should either have the role member or admin. Admins can create other users, members cannot.
Additionally, store a version table in the database with one column version with one row storing it as 1 for now. We will use this later if the database needs to be updated.
Note down for future agents that the database should only be for authentication related items and the store should handle everything else.
When testing, you should use an ephemeral memory database.
To prevent lockout, if a fleet bridge is being launched and a user is not detected, it should through stdin ask for a username and password to setup the first user as.
Ship to Bridge
Each ship should have its own FLEET_SHIP_TOKEN that's shared by the bridge and ship. The bridge will always provide the FLEET_SHIP_TOKEN when sending messages to the ship, and the ship will always provide it to the bridge when sending messages to it.
All tokens should be able to be configured with fleet launch
Important: scope it as narrowly as possible for SHIP -> BRIDGE calls. We don't want one compromised ship to compromise the whole bridge.
Web Client
The web client should support signing in and storing the session token.
Client CLI
The CLI should also store the session in ~/.local/state/fleet-client-cli/{url-of-bridge}/... If it doesn't exist, then the cli should prompt in stdin for the username and password to authenticate with.
Authentication for fleet should happen in several places:
Both the ship and the bridge should check
Authorization:headers.Outside to Bridge
All communications to the bridge should include a bearer token that identifies itself as a session to a specific user. Store users and sessions in a managed
bun:sqlitedatabase (abstract this into a Database class that manages and validates).Users should either have the role
memberoradmin. Admins can create other users, members cannot.Additionally, store a
versiontable in the database with one columnversionwith one row storing it as1for now. We will use this later if the database needs to be updated.Note down for future agents that the database should only be for authentication related items and the store should handle everything else.
When testing, you should use an ephemeral memory database.
To prevent lockout, if a fleet bridge is being launched and a user is not detected, it should through stdin ask for a username and password to setup the first user as.
Ship to Bridge
Each ship should have its own FLEET_SHIP_TOKEN that's shared by the bridge and ship. The bridge will always provide the FLEET_SHIP_TOKEN when sending messages to the ship, and the ship will always provide it to the bridge when sending messages to it.
All tokens should be able to be configured with
fleet launchImportant: scope it as narrowly as possible for SHIP -> BRIDGE calls. We don't want one compromised ship to compromise the whole bridge.
Web Client
The web client should support signing in and storing the session token.
Client CLI
The CLI should also store the session in ~/.local/state/fleet-client-cli/{url-of-bridge}/... If it doesn't exist, then the cli should prompt in stdin for the username and password to authenticate with.