Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(npmrc): add example of URI fragment limitations #8095

Closed
wants to merge 31 commits into from

Conversation

misse
Copy link

@misse misse commented Feb 10, 2025

Attempt to clarify limitations of how URI Fragments are not applied at the host level but at the path level and are not recursively applied to any sub-path.

When attempting to generate valid npmrc configuration files by using //host.name/:_auth=$token to cover any registry available at that host, I could not get npm to use those credentials.

I figured out the hard way that npm would only use the credentials if I specified the entire path up to the registry name i.e. //host.name/artifactory/api/npm/:auth=$token.

I felt the docs could be clarified to help other users realise the same.

lukekarrys and others added 30 commits September 13, 2022 14:21
Previously this was using `new URL` which would fail on some urls that
`hosted-git-info` is able to parse. But if we still get a url that can't
be parsed, we now set it to be removed from the tree instead of
erroring.

Fixes: npm#5278
* name and version description change

Reducing redundancy by deleting repeated code and changing other slight things about those two fields.
- [email protected]
- move doc workspace deps to dev deps
- remove @mdx-js/mdx
- @npmcli/[email protected]
Previously it would report the errors and require rerunning the script.
It's been safe enough that we know automatically remove the files. We
then run the `git ls-files` command again to make sure they were all
removed. Only if any are left do we error with a message requiring a
manual fix.
The `npm config` page redirects to itself in the "See also" section.
add closing parenthesis
Attempt to clarify limitations of how URI Fragments are not applied at the host level but at the path level and are not recursively applied to any sub-path.
@misse misse requested a review from a team as a code owner February 10, 2025 21:35
@wraithgar
Copy link
Member

This is a good start. While we're in here can we change somewhere-else.com to a domain that npm controls? somewhere-else.npmjs.org would work fine.

@misse
Copy link
Author

misse commented Feb 11, 2025

This is a good start. While we're in here can we change somewhere-else.com to a domain that npm controls? somewhere-else.npmjs.org would work fine.

Ok, will do. To confirm, it's expected that npm won't attempt to use the //host.name/:_auth= for any URL that contains https://host.name?

misse added a commit to misse/cli that referenced this pull request Feb 11, 2025
misse added a commit to misse/cli that referenced this pull request Feb 11, 2025
@wraithgar
Copy link
Member

Ok, will do. To confirm, it's expected that npm won't attempt to use the //host.name/:_auth= for any URL that contains https://host.name/?

Correct, it doesn't do domain matching it does whole uri matching.

This is where the lookup happens in npm for matching a uri with auth config.

For _auth the comparison and lookup is done here. The entire uri is used.

I believe in the past there was some fallthrough "host" checking that would do a "nearest path match" but that was removed in favor of absolutely explicit uri comparison, so as not to accidentally send tokens places where they were unexpected.

@wraithgar wraithgar changed the base branch from release/v8 to latest February 11, 2025 17:15
@wraithgar
Copy link
Member

It appears something has gone pear shaped in this PR, it all of a sudden has almost 100,000 lines of code changed. Please make sure you are making PRs against latest and that your local branch is up to date. We typically do not backport config updates.

@misse
Copy link
Author

misse commented Feb 11, 2025

Ok, will do. To confirm, it's expected that npm won't attempt to use the //host.name/:_auth= for any URL that contains https://host.name/?

Correct, it doesn't do domain matching it does whole uri matching.

This is where the lookup happens in npm for matching a uri with auth config.

For _auth the comparison and lookup is done here. The entire uri is used.

I believe in the past there was some fallthrough "host" checking that would do a "nearest path match" but that was removed in favor of absolutely explicit uri comparison, so as not to accidentally send tokens places where they were unexpected.

Thank you for confirming, this is what I'm trying to make more clear in the docs.

It appears something has gone pear shaped in this PR, it all of a sudden has almost 100,000 lines of code changed. Please make sure you are making PRs against latest and that your local branch is up to date. We typically do not backport config updates.

Oh, my bad. I'll revert those changes.

@misse
Copy link
Author

misse commented Feb 11, 2025

I will start over with a new MR.

@misse misse closed this Feb 11, 2025
@misse misse deleted the patch-1 branch February 11, 2025 17:53
misse added a commit to misse/cli that referenced this pull request Feb 11, 2025
 Update formatting for clarity, resolve lint MD040/fenced-code-language and change hostnames to npmjs.org subdomains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants