On this page

0252. Source config, mirrors, auth and proxies

Context

0237 allows credentials from user config or the root manifest. A cloned repository must not route a user's token to an arbitrary host. Teams need reproducible rules, private paths and air-gapped mirrors; 0238 describes discovery.

Decision

Narrow 0237: config is $XDG_CONFIG_HOME/harness/sources.toml (else $HOME/.config/harness/sources.toml) and root manifest [sources]. Every manifest accepts [sources] syntactically, but dependency and pack manifests ignore it without validation; offline builds read neither config. The user file has top-level [[registry]], [[mirror]], [[auth]] and [private] patterns = [..]; the root has [[sources.registry]], [[sources.mirror]] and [sources.private] patterns = [..]. TOML gains two-segment table arrays stored as TableArray entries in a plain parent table. Root [[sources.auth]] is E1083; credentials are user-only.

Online fetch loads source config when a pkg or https:// git dependency needs the network, so git mirrors apply in git-only graphs and git runs without any configured bearer_env variable. Path, edition-only, file/ssh git and offline loads never read it.

Project registry rules precede user rules and win on equal host; a duplicate host within one file remains E1075. Mirrors are unioned: longest matching from wins, project wins ties, and duplicate from in one file is E1083. Private patterns are unioned; user auth has at most one entry per host. C1 implements registry rules; C3 adds mirrors and private patterns; auth syntax and behavior are implemented in C4.

Mirrors rewrite fetch URLs for index files, release packs and git, never lock source. Pinned hashes keep lock bytes identical when mirrors change and detect tampering (E1066/E1077/E0937/E0949). A mirror is authoritative: no fallback on failure. Mirrors never apply to discovery probes or private packages. Private patterns are host/seg/..., where * matches exactly one segment and the pattern matches a path prefix by segments. Matching package and git URLs use no mirror and are never probed; discovery proceeds rule → built-in → git.

User [[auth]] specifies host = "h[:port]" and bearer_env = "VAR", where VAR matches [A-Z_][A-Z0-9_]*. Attach a token only to HTTPS requests whose authority exactly equals that host: never file URLs, another host, or a mirror of that host (a mirror host gets only its own auth). Read lazily; unset, empty or non-RFC 6750 b64token ([A-Za-z0-9._~+/-]+=*, at most 4096 characters) is E1084 without the value. Pass header = "Authorization: Bearer <t>" via curl stdin config (-K -), never argv, environment, lock or logs. With a token refuse redirects (--location --max-redirs 0; curl exit 47 is E1079, "redirect refused for an authenticated request"); never use --location-trusted. Git keeps its credential helpers, but fetch removes all configured bearer_env variables from git's environment. A credentials file is out of RG2.2 (Q1).

Curl retains its scrubbed environment plus HTTPS_PROXY, https_proxy, ALL_PROXY, all_proxy, NO_PROXY, no_proxy, not http_proxy (targets are HTTPS). Curl uses proxy userinfo; tokens travel inside CONNECT. Private does not bypass proxies: use NO_PROXY. One helper redacts every in-use token and proxy userinfo (whole user:pass and password) as *** in curl and git stderr before truncation to 160 characters.

Alternatives considered

Consequences

Project rules give shared lock sources while secrets stay outside repositories. Mirror failures require operator intervention; private users configure NO_PROXY separately. Later RG2.2 steps implement the planned features.