Repository navigation
computer: Hold Git credentials on the host with an auth resolver - #245
Draft
mattzcarey wants to merge 1 commit into
Draft
mattzcarey wants to merge 1 commit into
mattzcarey wants to merge 1 commit into
Conversation
The Git commands the model runs, the worker-shell `git` command and `ws:git`, had no way to authenticate. Host code could pass `headers` or `onAuth` on each typed call, but a model running `git clone` or `git push` against a private repository had to put a token on the command line, where it ends up in the transcript. createGitClient() now takes an `auth` resolver. The client calls it for every HTTPS request a clone, fetch, pull, or push makes, with the repository URL and whether the request reads or writes, and adds the credentials it returns as an Authorization header. The resolver wraps the HTTP transport rather than each command, so the typed API, cli(), the shell command, and ws:git all get it without their own plumbing. The token never reaches argv, the remote URL, .git/config, or output. An Authorization header passed on a call wins, and the resolver is not asked. Plain http:// requests never get credentials. Fixes #218.
馃 Changeset detectedLatest commit: 5b92ccd The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Git commands the model runs, the worker-shell
gitcommand andws:git, have no way to authenticate (#218). Host code can passheadersoronAuthon each typed call, but a model runninggit pushagainst a private repository has to put a token on the command line, where it ends up in the transcript.createGitClient()now takes anauthresolver. The client calls it for every HTTPS request a clone, fetch, pull, or push makes. It passes the repository URL and whether the request reads (fetch) or writes (push), then adds whatever credentials come back as anAuthorizationheader:The resolver wraps the HTTP transport rather than each command. That way the typed API,
cli(), the shell'sgitcommand andws:gitall get it, because the last two already run through the host's Git client. The token never reaches argv, the remote URL,.git/configor the output. Knowing the operation lets a host hand out a read-only token for fetches and a write token for pushes, for example short-lived Artifacts tokens.An
Authorizationheader passed on a call wins, and the resolver isn't asked. Plainhttp://requests never get credentials.The new
auth.test.tscovers the header shapes and the operation detection. It also checks that call headers win, that plain HTTP gets nothing, and UTF-8 encoding. It drives a realWorkspacethrough a typed clone, a CLI clone (checking the token isn't in the output) and a CLI push, using a transport that records requests and answers 401. Run it with:npm test --workspace @cloudflare/computer -- src/git/auth.test.tsThe auth section of
docs/13_git_interface.mdand the README's Git section describe the resolver. A minor changeset is included.Not covered here, and possible follow-ups from the issue:
ls-remoteisn't a CLI command yet.fetchdropping theAuthorizationheader across origins.