Skip to content

Commit 53037b3

Browse files
nlflukekarrys
authored andcommitted
chore(docs): add npmrc docs about scoping auth related config
1 parent 1e84102 commit 53037b3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/content/configuring-npm/npmrc.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,34 @@ consistent across updates. Set fields in here using the `./configure`
9191
script that comes with npm. This is primarily for distribution maintainers
9292
to override default configs in a standard and consistent manner.
9393

94+
### Auth related configuration
95+
96+
The settings `_auth`, `_authToken`, `username` and `_password` must all be
97+
scoped to a specific registry. This ensures that `npm` will never send
98+
credentials to the wrong host.
99+
100+
In order to scope these values, they must be prefixed by a URI fragment.
101+
If the credential is meant for any request to a registry on a single host,
102+
the scope may look like `//registry.npmjs.org/:`. If it must be scoped to a
103+
specific path on the host that path may also be provided, such as
104+
`//my-custom-registry.org/unique/path:`.
105+
106+
```
107+
; bad config
108+
_authToken=MYTOKEN
109+
110+
; good config
111+
@myorg:registry=https://somewhere-else.com/myorg
112+
@another:registry=https://somewhere-else.com/another
113+
//registry.npmjs.org/:_authToken=MYTOKEN
114+
; would apply to both @myorg and @another
115+
; //somewhere-else.com/:_authToken=MYTOKEN
116+
; would apply only to @myorg
117+
//somewhere-else.com/myorg/:_authToken=MYTOKEN1
118+
; would apply only to @another
119+
//somewhere-else.com/another/:_authToken=MYTOKEN2
120+
```
121+
94122
### See also
95123

96124
* [npm folders](/configuring-npm/folders)

0 commit comments

Comments
 (0)