Skip to content

fix: key every per-deployment store by origin - #1176

Open
EhabY wants to merge 1 commit into
mainfrom
fix/origin-keyed-stores
Open

EhabY wants to merge 1 commit into
mainfrom
fix/origin-keyed-stores

Conversation

@EhabY

@EhabY EhabY commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Every per-deployment store was keyed by hostname, so two deployments on one host with a different scheme or port shared sessions, OAuth client registrations, CLI config directories, SSH hosts, and the CLI binary cache. Signing in or out of one overwrote the other, and a window could connect to the wrong deployment. This builds on #1173, which made the origin the deployment's identity.

toSafeHost(url) now returns an origin label that every store already keys on:

Origin Label
https://host, https://host:443 host (unchanged)
https://host:8443 host_8443
http://host, http://host:80 host_http
http://host:8080 host_http8080
https://my_host my_host_https

Explicit default ports are dropped by URL parsing. Hostnames containing _ always get a suffix, so the text after the last _ is always the suffix, and its grammar (https, http[port], port) is unambiguous. A test checks every pair across schemes, ports, and look-alike hostnames: two URLs share a label exactly when they share an origin. Window addresses parse as before. The sign-in dialog refuses a URL for another origin, and getSessionAuth stays only for label-only callers.

Migration: HTTPS on port 443 is unchanged. Other origins sign in once more and download the CLI again. Old recent workspaces and links for them now point at the HTTPS origin; reopen them from the Coder sidebar.

toSafeHost returns an origin label (host for HTTPS on 443, else
host_<scheme><port>), so sessions, OAuth client registrations, CLI
config directories, SSH hosts, and the binary cache are per origin.

- Ignore entries an older version stored under the bare hostname for
  another origin; re-derive the saved deployment's label from its URL.
- Refuse another origin in the sign-in dialog before signing in.
- Keep getSessionAuth for label-only callers; the rest look up by URL.

This branch has not been deployed

No deployments
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