Conversation
|
💖 Thanks for opening this pull request! 💖 |
078f8d6 to
80dae65
Compare
We cannot add this back. It was removed both from npm and pnpm as it creates a security vulnerability. |
Can we do a registry origin check instead and then resolve the url only if it matches that domain or base path? |
|
I'll think about it later. @weswigham you were the one who reported the always-auth issue, so I would be happy to have your feedback here. |
|
@zkochan Since the first commit cannot be merged due to security reasons, I can remove it or make a new PR with only the HTTPS port fix. Related commit that should go in 9efa80a This will allow for scoped packages to resolve correctly if they have the |
…tion for thoses urls
9efa80a to
fb68e29
Compare
|
Renamed the PR and rebase dropped the always auth changes. This PR only contains the HTTPS port parsing logic now. |
|
Noting that the following needs to be done to replicate the issue.
Curiously only the artifactory urls fail that are unavailable externally. I'm wondering if it's defaulting to |
|
Can you cover this with a unit test? |
|
Please also handle the case with port |
| /** | ||
| * @artifactory adds a https port in the middle of their urls and URL.parse will not return ports in that range | ||
| */ | ||
| if (hasHTTPS && urlObj.port === '') { | ||
| return urlObj.href | ||
| } | ||
|
|
||
| if (urlObj.port === '') return originalUrl |
There was a problem hiding this comment.
It is probably just enough to do this:
| /** | |
| * @artifactory adds a https port in the middle of their urls and URL.parse will not return ports in that range | |
| */ | |
| if (hasHTTPS && urlObj.port === '') { | |
| return urlObj.href | |
| } | |
| if (urlObj.port === '') return originalUrl | |
| if (urlObj.port === '') return urlObj.href |
it will handle both :80 and :443
There was a problem hiding this comment.
@zkochan agreed. I added tests for http|https|ws|wss and moved the removePort method to it's own file so it can be tested without exporting it.
…tion for thoses urls
…breaking-artifactory-virtual-registries
…tion for thoses urls
…tion for thoses urls
|
Congrats on merging your first pull request! 🎉🎉🎉 |
…tifactory compatibility (#6864) Co-authored-by: Frederick Engelhardt <frederick.engelhardt@bestbuy.com> Co-authored-by: Zoltan Kochan <z@kochan.io>
Changes
* add compatibility back forRemoved due to security issue.always-auth=trueso the authorization is still passed to components not matching the registry urlsIssue
1.Removed due to security issue.pnpmwas deleting the authorization header, making registries that act as pass-through registries fail to fetch their tarball file download when attempting to access another registry with shared scope.2.
pnpmwas skipping https ports IE:443that artifactory was transforming. This caused a registry mismatch and it skipped authorization. This is related to URL which does not returnwell-knownports (0-1023) in the.portsparam. It still however parses and removes the https port.Solution
Initial fix:
1. Add a logic block to protect against deletion of authorization ifRemoved due to security issue.always-authis provided in.npmrc(<=Node16) or the pnpm config >=Node18.2. Adding a matcher for
:443fixes the port problem so that when communicating with artifactory the authorization is not removed due to url mismatch.Possible follow-up fixes related to auth (excluded from this PR scope)
registry=https://vllc.dev/artifactory/api/npm/npm-virtual/adding a second keyregistry-root=https://vllc.dev/artifactory/api/npm/would capture and add auth to all other registries in this structure and delete the rest.pnpm config file
Use case
This problem applies to all Artifactory registries with (>=2) registries and with scoped packages mixed across each registry. FYI this is a real world problem.
@platformcould resolve to multiple registries resolved by artifactory authorization.Due to a scoped package being unknown which registry to use, using the
@platform:registry=https://<company_domain>/artifactory/api/npm/npm-virtual/will not properly resolve the package correctly, this is because package-a could point tonpm-virtualbut package-b could point tonpm-virtual-v2and so on.Artifactory continues to recommend in npm v9 to use the
always-auth=trueflag (which is deprecated in 18).