fix: forward git auth to hosted CDN tarball downloads - #515
Open
dyk1454683243-sudo wants to merge 1 commit into
Open
dyk1454683243-sudo wants to merge 1 commit into
dyk1454683243-sudo wants to merge 1 commit into
Conversation
Hosted-git-info tarball URLs (codeload.github.com) omit git URL userinfo, and npm-registry-fetch looks up credentials by request host. Pass URL credentials and //<git-host>/ credential-store entries as forceAuth so the CDN request gets an Authorization header. Fixes: npm#331 Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
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.
Fixes #331
Cause
When installing a hosted git dependency (
git+https://oauth2:TOKEN@github.com/org/private.git), pacote prefers the provider CDN tarball (https://codeload.github.com/.../tar.gz/<sha>) overgit clone.hosted-git-info'starball()URL does not include git URL userinfo.npm-registry-fetchthen looks up credentials by the request host (codeload.github.com), so neither:oauth2:TOKEN@github.com), nor//github.com/:_authToken)are sent. GitHub returns 404 for the private archive, and pacote falls back to
git+ssh.Fix
When
GitFetchershells out toRemoteFetcherfor a hosted tarball, computeforceAuththe same way other authenticated pacote fetches do:hosted.auth) to HTTP Basic (percent-decoding first).//<git-host>/credential-store auth (_authToken→ Bearer,_auth/ username+password → Basic).Authorizationheader or a CDN-specific token (//codeload.github.com/:_authToken) alone.npm-registry-fetchthen setsAuthorizationon the CDN request.Tests
//github.com/:_authToken, Basic store entries, and CDN-host precedence.https://codeload.github.comand assert theAuthorizationheader on the tarball GET.This is distinct from #285 / #514 (hardlink extract filter).