fj auth login --fjord fails out of the box: DEFAULT_PLATFORM_URL points at the Cloudflare Access-protected pages.dev origin #250
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two independent problems make Fjord Account sign-in unusable without knowing the workaround. Both hit on the current release (0.4.1) on a headless Linux box.
1. The default platform URL is the pages.dev origin, which is behind Cloudflare Access
src/fjord/mod.rs:24:That host is protected by Cloudflare Access, so the device-authorization request gets an HTML sign-in page rather than JSON:
Passing the real production URL works immediately:
The device flow then starts correctly, prints the code and QR, and points at
https://fjord.sh/device.Suggested fix: default to
https://fjord.sh. A deployment-preview origin should not be the fallback for every user, and an Access-protected one can never work for a non-interactive client. Worth also detecting a non-JSON content type and saying "the platform URL is not serving the API, it returned an HTML page, check --platform-url" rather than surfacing a JSON decode error, which sends you looking at the wrong layer.2. An exported
FJ_TOKENblocks--fjordentirely--tokenis declared withenv = "FJ_TOKEN", so an exported token is treated as if it had been typed:The workaround is
env -u FJ_TOKEN fj auth login --fjord. NoteFJ_TOKEN= fj auth login --fjordis not enough, since an empty-but-set variable still reads as present.This matters more than a normal flag conflict because fj#147's own guidance is to export
FJ_TOKENfrom the shell profile to survive a locked keychain. Following the documented setup therefore makes--fjordunreachable in every shell.Suggested fix: only conflict when
--tokencame from the command line.src/cli/auth_login.rs:762already distinguishes an env-provided token from an explicit one, so the information exists and simply is not used for the conflict rule. An env token should be ignored in--fjordmode, or at most warned about.3. Related, the same env token is host-agnostic
src/auth/mod.rs:96: "Look up the token forhost: firstFJ_TOKEN, then keychain, then file."So
FJ_TOKENis presented to whatever host is targeted, and shadows any per-host credential. Concretely,fj api --host commons.fjord.hostsends the rasterhub.com PAT to commons and gets a 401, andfj auth status --host commons.fjord.hostreports rasterhub.com regardless. Signing into a second host does not take effect while the variable is exported.Both hosts here are ours so the exposure is small, but a credential for one forge being transmitted to another because of an environment variable is worth closing. Scoping it, for example
FJ_TOKEN_<HOST>or honouring it only for the current host, would fix the shadowing and the surprise together.Recording why this stayed closed, since a branch fixing it is still sitting on the remote.
fix/250-auth-fixesexists atb08c803("Fix Fjord auth defaults and token scoping"), is not an ancestor ofmain, and never had a PR opened. It surfaced tonight as stranded work on a lane. It is redundant: currentmainfixes all three problems by other commits, verified by reading the code rather than commit subjects.src/fjord/mod.rs:24ispub const DEFAULT_PLATFORM_URL: &str = "https://fjord.sh";, pinned bysrc/client/integration_tests.rs:573. The secondary ask landed too:src/fjord/mod.rs:180-204inspectsContent-Type, sniffs a leading<!doctype html/<html, and errors with "returned an HTML page rather than the Fjord platform API (HTTP {status}); check --platform-url" instead of a JSON decode error.FJ_TOKENblocking--fjord.src/cli/auth.rs:97-99declares--tokenas#[arg(long, hide_env_values = true)]. Theenv = "FJ_TOKEN"binding is gone, so an exported token no longer synthesizes the flag and cannot tripconflicts_with_all = ["token", "with_token"]on--fjordat line 111. Covered bysrc/cli/mod.rs:322.src/client/resolve.rs:61-80:generic_env_allowed_for_resolved_hostreturns true only when no--hostwas passed or when--hostnames the configured default, andpat_token_for_resolved_hosttriesauth::env_token_for_host(name)first.src/auth/mod.rs:191-205addsFJ_TOKEN_<HOST>. Sofj api --host commons.fjord.hostno longer sends the rasterhub.com PAT.So the branch can be deleted. Leaving that to the operator rather than doing it here, since it is the only copy of that work and nothing is gained by removing it today.
b08c803is recorded above if it is ever wanted.