|
9 | 9 | * observations and its mutation, and disposed with it — a completed replay |
10 | 10 | * restores its retained result without reaching this module at all. |
11 | 11 | * |
12 | | - * ## XMD is not the credential carrier |
| 12 | + * ## The adapter owns the credential, and owns it narrowly |
13 | 13 | * |
14 | | - * No credential value crosses this boundary, and none is written anywhere. What |
15 | | - * a session holds is the host's *decision* about which authentication Git may |
16 | | - * use for one exact locator: a socket path, a known-hosts file, and the names of |
17 | | - * the credential helpers the invoking user already configured. Git and the |
18 | | - * helper exchange the secret between themselves, over Git's own credential |
19 | | - * protocol, and this module never sees it. |
| 14 | + * This is the trusted host adapter, so it may hold one HTTP credential in |
| 15 | + * memory — for one invocation, released when that invocation ends. What it may |
| 16 | + * not do is let one out. The value reaches nothing but the private environment |
| 17 | + * of this invocation's own Git children, through a helper this provider wrote, |
| 18 | + * and it is not in an argument, a URL, a configuration file, a launcher, the |
| 19 | + * ambient environment, a context, the Workspace, a journal, retained identity, |
| 20 | + * rendered output, a diagnostic or a failure cause. |
20 | 21 | * |
21 | | - * That is why there is no `{ username, password }` here and no file for one to |
22 | | - * be written into. XMD acquires nothing to hand on: it says which mechanism is |
23 | | - * in force for one locator, and Git does the asking. Approving, rejecting, |
24 | | - * erasing, copying and persisting a credential are therefore things this |
25 | | - * provider cannot do rather than things it declines to do. |
| 22 | + * Acquisition asks the invoking user's ordinary helper chain once, about one |
| 23 | + * exact repository. That is where a platform keychain, a cached token or a |
| 24 | + * credential manager lives, and asking it is the whole point: a workflow reaches |
| 25 | + * a private clone wherever the equivalent local Git command reaches one. |
| 26 | + * |
| 27 | + * ## Two failures that must not be confused |
| 28 | + * |
| 29 | + * A host that holds no credential, an answer that is incomplete and an answer |
| 30 | + * about somewhere else are all *authentication unavailability* — ordinary live |
| 31 | + * conditions this run reports and continues past. A helper that could not be |
| 32 | + * installed, a `git credential fill` that could not be run, a marker that could |
| 33 | + * not be read: those are the machine failing to provide a mechanism, and they |
| 34 | + * fail the run stop. Reporting infrastructure as "no credential" would turn a |
| 35 | + * broken host into a clean refusal. |
26 | 36 | * |
27 | 37 | * ## Why the host decides, and the checkout cannot |
28 | 38 | * |
29 | 39 | * `host.ts` builds Git's environment from nothing precisely so a workflow's |
30 | 40 | * behavior does not depend on whose machine created it. Configuration is still |
31 | | - * built from nothing: `GIT_CONFIG_GLOBAL`, `GIT_CONFIG_SYSTEM` and |
32 | | - * `GIT_CONFIG_NOSYSTEM` stay as they were, so no `~/.gitconfig` URL rewrite, |
33 | | - * `core.hooksPath` or `init.templateDir` is read. What a session adds is the |
34 | | - * narrow set of things a standard credential helper needs in order to reach the |
35 | | - * user's own keychain or store, and the helper names themselves, re-stated on |
36 | | - * the command line where this provider chose them rather than inherited them. |
37 | | - * |
38 | | - * The retained checkout has no say at all. A `.git/config` a document wrote is |
| 41 | + * built from nothing, and the transport's arguments reset ambient credential |
| 42 | + * helpers and install only the provider-owned one — no ambient `credential.*` |
| 43 | + * definition or value is copied there. A `.git/config` a document wrote is |
39 | 44 | * inside the Workspace and restored by replay, so a `credential.helper` or a |
40 | | - * `core.sshCommand` in one would be document-authored data naming a program. |
41 | | - * Both are fixed on the command line — where they outrank every configuration |
42 | | - * file — for every invocation that transports to a remote, and the |
43 | | - * `credential.helper` list is reset before the host's own choice is stated. |
| 45 | + * `core.sshCommand` in one would be document-authored data naming a program; |
| 46 | + * both are fixed on the command line, where they outrank every configuration |
| 47 | + * file, for every invocation that transports to a remote. |
44 | 48 | * |
45 | 49 | * ## What each transport borrows |
46 | 50 | * |
47 | 51 | * **SSH** borrows the agent, and only the agent. `HOME` stays the disposable |
48 | 52 | * materialization, so no key file on the machine is reachable and no |
49 | | - * `~/.ssh/config` is read; `IdentityAgent` names the ambient socket outright, so |
50 | | - * the keys this run can offer are exactly the ones the invoking user has |
51 | | - * unlocked. Host verification stays on and its material is the invoking user's |
| 53 | + * `~/.ssh/config` is read; `IdentityAgent` names the ambient socket outright. |
| 54 | + * Host verification stays on and its material is the invoking user's |
52 | 55 | * `known_hosts`, selected here rather than found: an unknown host is a refusal, |
53 | 56 | * never a key accepted on this run's behalf. |
54 | 57 | * |
55 | | - * **HTTP** borrows the credential helpers the invoking user configured, and the |
56 | | - * environment those helpers need to answer. Git queries them for the exact URL |
57 | | - * it is transporting to, which is a more exact question than this module could |
58 | | - * ask on its behalf. `core.excludesFile` and `core.attributesFile` are pinned |
59 | | - * alongside, because with configuration itself off they are the only remaining |
60 | | - * things a passed-through `HOME` would decide. |
| 58 | + * **HTTP** borrows one answer from the user's helper chain, and hands it onward |
| 59 | + * only through the provider-owned helper described in `credential-helper.ts`. |
61 | 60 | */ |
62 | 61 |
|
63 | 62 | import { ensure, type Operation, resource, until } from "effection"; |
@@ -373,21 +372,19 @@ export function denoCredentialBroker( |
373 | 372 | env["SSH_ASKPASS"] = ""; |
374 | 373 | env["LC_ALL"] = "C"; |
375 | 374 |
|
376 | | - let outcome: { code: number; stdout: string }; |
377 | | - try { |
378 | | - outcome = yield* runProcess({ |
379 | | - command: "git", |
380 | | - args: ["-c", "credential.useHttpPath=true", "credential", "fill"], |
381 | | - cwd: directory, |
382 | | - env, |
383 | | - input: |
384 | | - `protocol=${request.protocol}\nhost=${request.host}\n` + |
385 | | - `${request.path === undefined ? "" : `path=${request.path}\n`}\n`, |
386 | | - }); |
387 | | - } catch { |
388 | | - yield* provide(unacquired()); |
389 | | - return; |
390 | | - } |
| 375 | + // No `try` around this. A `git credential fill` that could not be |
| 376 | + // started, or that failed in a way this host cannot run past, is the |
| 377 | + // machine failing to provide a mechanism rather than a machine that |
| 378 | + // holds no credential — and the two must not report the same thing. |
| 379 | + const outcome = yield* runProcess({ |
| 380 | + command: "git", |
| 381 | + args: ["-c", "credential.useHttpPath=true", "credential", "fill"], |
| 382 | + cwd: directory, |
| 383 | + env, |
| 384 | + input: |
| 385 | + `protocol=${request.protocol}\nhost=${request.host}\n` + |
| 386 | + `${request.path === undefined ? "" : `path=${request.path}\n`}\n`, |
| 387 | + }); |
391 | 388 | if (outcome.code !== 0) { |
392 | 389 | yield* provide(unacquired()); |
393 | 390 | return; |
|
0 commit comments