@@ -91,6 +91,34 @@ consistent across updates. Set fields in here using the `./configure`
91
91
script that comes with npm. This is primarily for distribution maintainers
92
92
to override default configs in a standard and consistent manner.
93
93
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
+
94
122
### See also
95
123
96
124
* [ npm folders] ( /configuring-npm/folders )
0 commit comments