Files
pipelines/app/notes/server-credential-scopes.md
T

1.9 KiB

Logical-server credential scopes

  • Call await ServerSession.activateServer(id: ..., endpoints: ..., migrateLegacy: false) before connecting a selected profile. serverId reports its id. Aliases explicitly share that profile's cookie; the id, not the hostname, owns persistence.
  • headersFor(Uri) allows only exact HTTP-normalized scheme/host/port aliases, rejects userinfo and unsupported schemes, and returns no cookie for other origins. WebSocket, artifact, upload and update IO consumers use it. WebSocket and update redirects are disabled to prevent redirect-based cookie forwarding.
  • Scoped preference keys are pipelines.session.v2.${Uri.encodeComponent(id)}.cookie. Empty values persist sign-out, preventing legacy re-import. Migration is opt-in and only imports when no scoped value exists; migration and scoped sign-out leave the legacy key untouched.
  • load() resets the selected profile and trust configuration. Legacy .cookie and .headers remain available; pre-profile requests bind their one trusted origin through check or successful signIn.
  • Activation clears the active cookie before awaiting storage. Generation guards prevent stale activation/login responses from publishing across profile switches. Late login persists only its initiating profile; signing out cancels pending login writes for that profile.
  • Focused coverage includes aliases, origin rejection, shared-host profile isolation, signed-out profiles, explicit one-time migration, concurrent activation, late login, sign-out races, actual native request headers, and update/WebSocket redirect rejection. Fixtures use loopback HTTP/WebSocket listeners only; no production or device mutations.

Checks: flutter test --no-pub test/core/session test/core/transport test/features/updates/app_updates_test.dart passed (30 tests); flutter analyze --no-pub reported no issues; git diff --check passed. Device behavior and deployment were not tested.