Secure connectivity and credentials
Pipedash lets a web, desktop, or mobile client use a local core or connect to a remote host. It keeps host access separate from provider sign-in and protects provider credentials behind a vault. Pairing gives a client a device identity. A vault session lets the host use stored provider credentials without sending those credentials to the client.
System boundary
The connection system has three security boundaries. The client must first reach a Pipedash host. It must then prove that it may use that host. Provider credentials are a separate concern and become available only after the host opens its vault.
The main terms are:
- Host: The Pipedash server or desktop process that serves data and runs provider work.
- Client: A browser or desktop/mobile UI that talks to a host.
- Pairing: The one-time process that gives a client a stored device token.
- Vault: The protected store for provider credentials.
- Provider sign-in: Authorization to an external system such as a source-control or deployment service.
Connection modes
The UI supports local work and remote work. The selected mode decides where the core service runs and which connection path carries API requests.
Standalone sessions
In standalone mode, the client uses the local core directly. The desktop app can run its own core. A web deployment uses its host through normal HTTP and WebSocket interfaces. A local desktop session does not need device pairing.
References: src/…/connection.ts• L8-34 src/…/WelcomeScreen.tsx• L66-79 crates/…/vault.rs• L61-82
Remote client sessions
In client mode, the UI connects to a server or desktop host over a WebSocket session. The desktop client keeps connection details separate from its device token. The details help it find the host again. The token proves that the paired device may still connect.
References: src/…/connection.ts• L8-48 src/…/WelcomeScreen.tsx• L15-20 crates/…/store.rs• L14-49 crates/…/store.rs• L88-108
Connection establishment
Connection setup combines address checks, transport setup, and host access. The client accepts a server address or a pairing link. It can also scan a pairing QR code on mobile. Secure WebSocket transport is required for public HTTPS hosts. Plain HTTP needs clear consent and is limited to private network addresses.
The high-level connection flow is:
flowchart TD
A[Choose local or remote host] --> B{Remote?}
B -- No --> C[Use local core]
B -- Yes --> D[Enter address or scan pairing link]
D --> E{Secure transport?}
E -- No --> F[Confirm trusted private HTTP]
E -- Yes --> G[Use secure transport]
F --> G
G --> H[Submit pairing code or link]
H --> I[Enroll or authenticate device]
I --> J[Show remote host data]
The connection screen keeps transport consent tied to the address that produced the warning. Changing the address clears that consent. A successful connection can either show the remote host's pipelines or enable alerts from that host while the device keeps its own local pipelines.
Transport authentication
The host does not admit client requests until the WebSocket handshake has an accepted identity. A host may accept an operator token or a token for a paired device. After authentication, it returns the host identity and enables request and event traffic.
The browser WebSocket client reconnects when the link fails. It stops retrying after repeated authentication failures until the user unlocks the vault or starts a manual reconnect. This prevents a stale secret from causing an endless connection loop.
References: crates/…/ws.rs• L256-323 crates/…/ws.rs• L354-398 src/…/websocket.ts• L102-215 crates/…/session.rs• L201-307 src/…/ConnectServerForm.tsx• L83-121
Pairing
Pairing is the enrollment path for a new client. A host creates a short-lived code and a link that can also be shown as a QR code. The client submits the code with its name and platform. The host accepts the code once, creates a device identity, and returns a device token for later sessions.
Pairing codes expire after five minutes and a code cannot be reused. The host stores a hash of the device token rather than the token itself. A removed device therefore loses access even if the client still has its old saved connection.
For the detailed pairing contract, see Authentication and pairing.
References: crates/…/pairing.rs• L25-88 crates/…/pairing_codes.rs• L26-66 crates/…/ws.rs• L400-439 crates/…/pairing.rs• L175-215 src/…/ConnectServerForm.tsx• L122-173
Provider sign-in
Provider sign-in is separate from connecting to Pipedash. It gives a provider integration an access credential without changing the client's host identity. This separation lets several clients use one host while the host manages provider access in one place.
Provider authorization
The UI starts a provider sign-in flow and receives an authorization URL. A browser opens that URL for web and desktop use. Mobile uses a native authentication session. The UI then checks the flow status and completes or cancels the flow. When a provider credential expires, the same flow supports reconnecting that provider.
sequenceDiagram
participant UI as Client UI
participant Host as Pipedash host
participant IdP as Provider sign-in service
UI->>Host: Start provider sign-in
Host-->>UI: Authorization URL and flow ID
UI->>IdP: Open authorization session
IdP-->>Host: Authorization result
UI->>Host: Check or complete flow
Host-->>UI: Sign-in status
Host->>Host: Store provider credential in vault
The provider service validates credentials and can refresh credentials when the provider supports renewal. A provider with no credentials remains read-only and cannot perform actions that require access.
References: src/…/api.ts• L393-447 crates/…/sign_in.rs• L27-131 crates/…/provider_service.rs• L280-332 crates/…/pipeline_service.rs• L49
For the sign-in state machine and pairing protocol, see Authentication and pairing.
Storage and vault setup
The setup flow creates or changes the local storage and vault settings before the client starts provider work. It checks the proposed settings before saving them. When an existing store changes location, it can transfer providers, credentials, history, cache entries, and metrics as one migration or leave them in the old location by explicit choice.
The flow serves both first-run onboarding and later storage settings. It adapts its steps for desktop, server, and mobile shells while keeping the same save boundary. A completed setup may require a local core restart before the new database is used.
Vault password setup
The setup flow asks for a vault password and confirms it before it enables saving. When a desktop or server host must unlock automatically, the success view reminds the operator to place the password in the configured environment variable. Mobile setup does not expose the same host-side environment reminder.
References: src/…/SetupWizard.tsx• L11-69 src/…/SetupWizardSession.tsx• L56-104 src/…/usePreparedSetup.ts• L19-39 src/…/useSetupSubmission.ts• L48-87 src/…/SuccessStep.tsx• L23-43 src/…/PasswordReminderCard.tsx• L8-43
Storage migration
Storage changes are prepared against the latest draft before they are applied. A migration can move the provider records and their encrypted tokens to the new store. Skipping transfer keeps the old data in the previous location and makes it unavailable after the switch.
The setup UI reports storage-read, preparation, and save failures as separate recoverable states. This keeps an invalid configuration or a failed migration from appearing as a successful connection.
References: src/…/SetupWizardActions.tsx• L5-22 src/…/SetupWizardSession.tsx• L73-181 src/…/useSetupSubmission.ts• L58-84 src/…/SetupWizard.test.ts• L129-225 src/…/ConfigErrorScreen.tsx• L8-40
Credential and vault access
The vault controls when provider credentials can be read. A host reports whether the vault is locked, whether a password is needed, and where the current password came from. Unlocking creates a usable credential session and loads provider access.
Vault lifecycle
The client reads vault status before it asks for a password. On unlock, it sends the password to the host and keeps the accepted value as the active session token. A failed unlock clears that token. Locking clears the active client token and marks the host vault as unavailable for new credential reads.
The persistent token stores support SQLite and PostgreSQL. SQLite requires a vault password. PostgreSQL can use a supplied password or the configured environment password. Without one, it uses an ephemeral vault that does not provide persistent protected credentials.
Vaults created with an older key setup can move to a per-vault random salt when they are opened with the right password. The old data remains usable during this transition. A wrong password cannot claim or rewrite the old vault.
References: crates/…/vault.rs• L24-40 crates/…/vault.rs• L61-138 crates/…/vault.rs• L140-260 src/…/useVaultQueries.ts• L18-105 src/…/authStore.ts• L24-83 crates/…/vault.rs• L61-138 crates/…/sqlite.rs• L30-47 crates/…/postgres.rs• L34-61
Credential boundaries
Provider tokens are encrypted at rest and are loaded only after the vault accepts its password. The active host session can read them for provider work. The client UI does not need to receive each provider token. The desktop remote token follows a different boundary: it is a device credential stored in the platform keychain, while non-secret connection metadata is stored separately.
Vault export and import use a separate password for the encrypted backup. This lets an operator move provider credentials without exposing them as plain data during the transfer. The backup format uses a fresh salt and nonce, so a backup password is not the same as the host vault password.
For the full credential and vault model, see Credential and vault handling.
References: crates/…/crypto.rs• L23-109 crates/…/vault.rs• L141-255 crates/…/sqlite.rs• L105-182 crates/…/postgres.rs• L123-184 crates/…/store.rs• L40-108 crates/…/credential.rs• L1-53
Client interfaces
The same security model crosses browser, desktop, and mobile UI layers. Each layer changes how it opens a sign-in page or stores a session, but the host still makes the final access decision.
Connection screens
The connection screens first let the user choose local work or a remote host. They then accept a host address, pairing link, pairing code, or mobile QR scan. They show a clear recovery path when a host is unreachable or when the host removes the device. A successful connection leads to the dashboard or to notification settings when the user connected only for alerts.
References: src/…/WelcomeScreen.tsx• L66-138 src/…/ConnectServerScreen.tsx• L16-69 src/…/ConnectServerForm.tsx• L122-193 src/…/ConnectServerDone.tsx• L10-53 src/…/HostUnreachableScreen.tsx• L18-89 src/…/ServerAccessGate.tsx• L16-81
Web interface
The web UI keeps the current vault or host token in its auth store and sends it when it opens or reauthenticates a WebSocket. A rejected token clears the session after repeated failures and prompts the user to unlock the vault again. Provider sign-in opens a separate browser tab and reports its flow state through the host API.
References: src/…/authStore.ts• L5-25 src/…/websocket.ts• L77-99 src/…/websocket.ts• L124-170 src/…/api.ts• L412-447
Desktop and mobile interfaces
The desktop UI can run locally or act as a remote client. In remote mode it uses a native connection service and stores the device token in the platform credential store. Desktop sign-in opens the system browser. Mobile uses a native authentication session and closes it when the host reports completion. Mobile connection onboarding also supports QR scanning and a full-screen setup layout.
References: src/…/connection.ts• L24-49 crates/…/session.rs• L84-107 crates/…/store.rs• L88-108 crates/…/sign_in.rs• L85-130 src/…/ConnectServerForm.tsx• L213-231 src/…/SetupWizardLayout.tsx• L90-120
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the host WebSocket auth frames aligned with both the browser client and the desktop remote client.
- Keep pairing-code expiry, one-time use, device token issuance, and device lookup as one contract.
- Keep the vault unlock result aligned with client token state so failed unlocks cannot leave an apparently active session.
- Keep provider sign-in completion aligned across browser redirects, desktop browser handoff, and mobile native sessions.
- Keep remote connection metadata separate from the device token when changing saved connection formats.
- Keep private-HTTP consent tied to the exact address that requested it.
- Keep setup preparation and apply results aligned with migration results and the restart needed by a local core.
- Keep SQLite and PostgreSQL vault behavior aligned for password checks, legacy upgrades, token reads, and encrypted backup transfer.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An expired or invalid host token is reused | The host rejects the WebSocket and the client loses event access | Clear the client session after repeated auth failures and require a new unlock or reconnect |
| A pairing code is expired or already claimed | The new client cannot enroll | Issue a fresh code; codes are short-lived and single-use |
| A vault password does not decrypt the verifier or provider tokens | The vault stays locked and provider work cannot load credentials | Reject the unlock and do not replace the active credential store |
| A public host is reached over plain HTTP | The remote client refuses the connection before sending credentials | Use HTTPS for public hosts; allow plain HTTP only for private addresses after explicit consent |
| Private-HTTP consent is reused after the address changes | The client may send access data to a different unencrypted host | Clear consent whenever the submitted address changes |
| A paired device is removed | Its saved token no longer authenticates | Show the access-revoked state and re-pair the client |
| Setup preparation or apply fails | The new storage choice is not safe to present as active | Keep the wizard on the failing step and allow a retry |
| Storage is changed without data transfer | Providers, credentials, and history remain in the old location | Warn before the switch and transfer data when it must remain available |
| A legacy vault upgrade races with another process or cannot save its verifier | The vault may keep its old key setup or reopen with the newer one | Claim the upgrade transactionally and keep the old vault usable when upgrade saving fails |
Key files
| File | Why to read it |
|---|---|
| src/…/connection.ts | Defines the UI's local and remote connection modes. |
| src/…/WelcomeScreen.tsx | Shows the product choice between local work and a remote host. |
| src/…/ConnectServerForm.tsx | Shows address, pairing, QR, and private-HTTP connection onboarding. |
| src/…/HostUnreachableScreen.tsx | Shows retry and disconnect behavior when the host cannot be reached. |
| src/…/ServerAccessGate.tsx | Shows how revoked device access stops normal use. |
| crates/…/ws.rs | Shows the host-side authentication and pairing boundary. |
| crates/…/pairing.rs | Shows how a host creates a pairing offer. |
| crates/…/pairing.rs | Defines host URL rules, pairing links, and device identity behavior. |
| src/…/SetupWizardSession.tsx | Shows the high-level storage setup and migration flow. |
| src/…/useSetupSubmission.ts | Shows validation before storage settings are applied. |
| crates/…/vault.rs | Defines vault status, unlock, and lock behavior at the host boundary. |
| crates/…/vault.rs | Shows the vault password boundary, token loading, and key transition. |
| crates/…/sqlite.rs | Shows persistent vault access for local SQLite storage. |
| crates/…/postgres.rs | Shows persistent vault access for PostgreSQL storage. |
| crates/…/crypto.rs | Shows the protected backup boundary and vault encryption model. |
| crates/…/store.rs | Separates saved remote connection metadata from the device token. |
| crates/…/sign_in.rs | Shows desktop and mobile provider sign-in handoff. |