Let auth login reach a beta preview on a private network
basecamp auth login can't sign in to a beta preview. A preview serves its API at <name>-api.3.bc4-beta.com, and that name resolves to the previews load balancer at a private address on the VPN. OAuth requests refuse private addresses, so discovery failed and login quietly fell back to Launchpad without saying why.
This adds an explicit opt-in: BASECAMP_OAUTH_ALLOW_PRIVATE=1.
- It admits RFC 1918 addresses, over HTTPS, on the BC5 OAuth lane of a non-production base URL, and only for the base URL's host and hosts under its parent domain (
*.3.bc4-beta.comfor a preview). The scope never extends to a public suffix (co.uk,github.io), so a discovery document or a redirect can't send the CLI anywhere else on the private network. - The lane's strict policy still judges every other address. Loopback, link-local, cloud metadata, IPv6 private space (which holds GCP's, OCI's and AWS's IPv6 metadata services) and the rest of the IANA special-use space stay refused. Each dial is checked again when it connects.
- The default deny is unchanged. The Launchpad lane never takes the opt-in, and for Basecamp's own hosts it is ignored with a warning.
- Without the opt-in, a failed discovery against a base URL that resolves only to private addresses now prints a hint that names the variable.
- On the opted-in path, legacy numeric hosts (
0x0a1405e5) are refused, and URL shape is checked without a DNS lookup.
Verification
Run against the live main beta preview over the VPN (main-api.3.bc4-beta.com resolves to 10.20.5.229):
$ BASECAMP_BASE_URL=https://main-api.3.bc4-beta.com basecamp auth login --device-code
warning: OAuth discovery failed for https://main-api.3.bc4-beta.com, using Launchpad fallback
hint: the base URL resolves to a private network address, which OAuth refuses by default; if you trust it (a beta preview on the VPN), set BASECAMP_OAUTH_ALLOW_PRIVATE=1
$ BASECAMP_OAUTH_ALLOW_PRIVATE=1 BASECAMP_BASE_URL=https://main-api.3.bc4-beta.com basecamp auth login --device-code
Authenticating via https://main.3.bc4-beta.com (device flow)
1. Open this link on any device
https://main.3.bc4-beta.com/oauth/device_verification?user_code=…
$ BASECAMP_OAUTH_ALLOW_PRIVATE=1 basecamp auth login --device-code # production
warning: BASECAMP_OAUTH_ALLOW_PRIVATE=1 is ignored for a production base URL; OAuth requests keep the SSRF address policy
Authenticating via https://app.basecamp.com (device flow)
With the opt-in on, discovery, the issuer's metadata and the device-authorization POST all reach the preview, which hands back a code. I didn't approve the code in a browser, so the token exchange at the end wasn't run live. Polling uses the same lane as the device POST.
Unit tests pin what the opt-in admits and refuses, the dial check, the production and malformed-value cases, the Launchpad lane, numeric hosts and the hint. None of them depend on the surrounding network. bin/ci is green. A security review over two rounds found four gaps: the IPv6 metadata services, a lane-wide scope, the public-suffix boundary and plain-HTTP redirects. All four are fixed in this PR, and the second round found nothing further.
Summary by cubic
basecamp auth login can now reach a beta preview whose API host resolves to a private address on the VPN, which OAuth requests previously refused and silently fell back to Launchpad for. BASECAMP_OAUTH_ALLOW_PRIVATE=1 opts the BC5 OAuth lane into private addresses for a non-production base URL.
- Admits only RFC 1918 space, over HTTPS, for the base URL's host and hosts under its parent domain; loopback, link-local, cloud metadata, CGNAT, IPv6 unique local space, and public suffixes stay refused, and each dial is checked again at connect time.
- The pre-dial shape check no longer resolves the host, so requests (each device-code poll included) don't wait on DNS before dialing.
- The Launchpad lane never takes the opt-in, and it is ignored with a warning for Basecamp's own hosts, so production discovery can't be steered to an internal address.
- Without the opt-in, a failed discovery against a private-only base URL now prints a hint naming the variable.
- On the opted-in lane, legacy numeric hosts (like
0x0a1405e5) are refused.