@verdaccio/auth 6.0.0-6-next.55 → 7.0.0-next-7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +414 -0
- package/LICENSE +1 -1
- package/build/auth.d.ts +7 -26
- package/build/auth.js +43 -31
- package/build/auth.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/signature-legacy.d.ts +5 -0
- package/build/signature-legacy.js +60 -0
- package/build/signature-legacy.js.map +1 -0
- package/build/signature.d.ts +4 -0
- package/build/signature.js +60 -0
- package/build/signature.js.map +1 -0
- package/build/types.d.ts +34 -0
- package/build/types.js +13 -0
- package/build/types.js.map +1 -0
- package/build/utils.d.ts +5 -15
- package/build/utils.js +19 -9
- package/build/utils.js.map +1 -1
- package/package.json +13 -12
- package/src/auth.ts +66 -59
- package/src/index.ts +1 -0
- package/src/signature-legacy.ts +66 -0
- package/src/signature.ts +66 -0
- package/src/types.ts +46 -0
- package/src/utils.ts +37 -31
- package/test/auth.spec.ts +561 -40
- package/test/helper/plugin.ts +8 -0
- package/test/partials/plugin/verdaccio-access-ok/access.js +9 -0
- package/test/partials/plugin/verdaccio-access-ok/package.json +5 -0
- package/test/partials/plugin/verdaccio-adduser/adduser.js +25 -0
- package/test/partials/plugin/verdaccio-adduser/package.json +5 -0
- package/test/partials/plugin/verdaccio-adduser-legacy/adduser.js +25 -0
- package/test/partials/plugin/verdaccio-adduser-legacy/package.json +5 -0
- package/test/partials/plugin/verdaccio-change-password/change.js +32 -0
- package/test/partials/plugin/verdaccio-change-password/package.json +5 -0
- package/test/partials/plugin/verdaccio-fail/fail.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,419 @@
|
|
|
1
1
|
# @verdaccio/auth
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next-7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@7.0.0-next-7.7
|
|
8
|
+
- @verdaccio/config@7.0.0-next-7.7
|
|
9
|
+
- @verdaccio/loaders@7.0.0-next-7.7
|
|
10
|
+
- verdaccio-htpasswd@12.0.0-next-7.7
|
|
11
|
+
- @verdaccio/utils@7.0.0-next-7.7
|
|
12
|
+
- @verdaccio/signature@7.0.0-next.3
|
|
13
|
+
- @verdaccio/logger@7.0.0-next-7.7
|
|
14
|
+
|
|
15
|
+
## 7.0.0-next.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [4d96324]
|
|
20
|
+
- @verdaccio/config@7.0.0-next.6
|
|
21
|
+
- @verdaccio/loaders@7.0.0-next.6
|
|
22
|
+
- verdaccio-htpasswd@12.0.0-next.6
|
|
23
|
+
- @verdaccio/signature@7.0.0-next.3
|
|
24
|
+
- @verdaccio/core@7.0.0-next.6
|
|
25
|
+
- @verdaccio/utils@7.0.0-next.6
|
|
26
|
+
- @verdaccio/logger@7.0.0-next.6
|
|
27
|
+
|
|
28
|
+
## 7.0.0-next.5
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [f047cc8]
|
|
37
|
+
- @verdaccio/core@7.0.0-next.5
|
|
38
|
+
- @verdaccio/signature@7.0.0-next.3
|
|
39
|
+
- @verdaccio/config@7.0.0-next.5
|
|
40
|
+
- @verdaccio/loaders@7.0.0-next.5
|
|
41
|
+
- @verdaccio/logger@7.0.0-next.5
|
|
42
|
+
- verdaccio-htpasswd@12.0.0-next.5
|
|
43
|
+
- @verdaccio/utils@7.0.0-next.5
|
|
44
|
+
|
|
45
|
+
## 7.0.0-next.4
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [312bc100f]
|
|
50
|
+
- @verdaccio/signature@7.0.0-next.2
|
|
51
|
+
- @verdaccio/core@7.0.0-next.4
|
|
52
|
+
- @verdaccio/config@7.0.0-next.4
|
|
53
|
+
- @verdaccio/loaders@7.0.0-next.4
|
|
54
|
+
- verdaccio-htpasswd@12.0.0-next.4
|
|
55
|
+
- @verdaccio/utils@7.0.0-next.4
|
|
56
|
+
- @verdaccio/logger@7.0.0-next.4
|
|
57
|
+
|
|
58
|
+
## 7.0.0-next.3
|
|
59
|
+
|
|
60
|
+
### Major Changes
|
|
61
|
+
|
|
62
|
+
- e7ebccb61: update major dependencies, remove old nodejs support
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [daceb6d87]
|
|
67
|
+
- Updated dependencies [e7ebccb61]
|
|
68
|
+
- @verdaccio/config@7.0.0-next.3
|
|
69
|
+
- @verdaccio/core@7.0.0-next.3
|
|
70
|
+
- verdaccio-htpasswd@12.0.0-next.3
|
|
71
|
+
- @verdaccio/signature@7.0.0-next.1
|
|
72
|
+
- @verdaccio/utils@7.0.0-next.3
|
|
73
|
+
- @verdaccio/loaders@7.0.0-next.3
|
|
74
|
+
- @verdaccio/logger@7.0.0-next.3
|
|
75
|
+
|
|
76
|
+
## 7.0.0-next.2
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- @verdaccio/core@7.0.0-next.2
|
|
81
|
+
- @verdaccio/config@7.0.0-next.2
|
|
82
|
+
- @verdaccio/loaders@7.0.0-next.2
|
|
83
|
+
- verdaccio-htpasswd@12.0.0-next.2
|
|
84
|
+
- @verdaccio/utils@7.0.0-next.2
|
|
85
|
+
- @verdaccio/signature@7.0.0-next.0
|
|
86
|
+
- @verdaccio/logger@7.0.0-next.2
|
|
87
|
+
|
|
88
|
+
## 7.0.0-next.1
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- @verdaccio/core@7.0.0-next.1
|
|
93
|
+
- @verdaccio/config@7.0.0-next.1
|
|
94
|
+
- @verdaccio/loaders@7.0.0-next.1
|
|
95
|
+
- verdaccio-htpasswd@12.0.0-next.1
|
|
96
|
+
- @verdaccio/utils@7.0.0-next.1
|
|
97
|
+
- @verdaccio/signature@7.0.0-next.0
|
|
98
|
+
- @verdaccio/logger@7.0.0-next.1
|
|
99
|
+
|
|
100
|
+
## 7.0.0-next.0
|
|
101
|
+
|
|
102
|
+
### Major Changes
|
|
103
|
+
|
|
104
|
+
- feat!: bump to v7
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
- @verdaccio/config@7.0.0-next.0
|
|
110
|
+
- @verdaccio/core@7.0.0-next.0
|
|
111
|
+
- @verdaccio/loaders@7.0.0-next.0
|
|
112
|
+
- @verdaccio/logger@7.0.0-next.0
|
|
113
|
+
- verdaccio-htpasswd@12.0.0-next.0
|
|
114
|
+
- @verdaccio/signature@7.0.0-next.0
|
|
115
|
+
- @verdaccio/utils@7.0.0-next.0
|
|
116
|
+
|
|
117
|
+
## 6.0.0
|
|
118
|
+
|
|
119
|
+
### Major Changes
|
|
120
|
+
|
|
121
|
+
- 292c0a37f: feat!: replace deprecated request dependency by got
|
|
122
|
+
|
|
123
|
+
This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
|
|
124
|
+
|
|
125
|
+
## Notes
|
|
126
|
+
|
|
127
|
+
- Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
|
|
128
|
+
- Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
|
|
129
|
+
- Refactor with promises instead callback wherever is possible
|
|
130
|
+
- ~Document the API~
|
|
131
|
+
- Improve testing, integration tests
|
|
132
|
+
- Bugfix
|
|
133
|
+
- Clean up old validations
|
|
134
|
+
- Improve performance
|
|
135
|
+
|
|
136
|
+
## 💥 Breaking changes
|
|
137
|
+
|
|
138
|
+
- Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
|
|
139
|
+
- Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
|
|
140
|
+
- `@verdaccio/streams` stream abort support is legacy is being deprecated removed
|
|
141
|
+
- Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
|
|
142
|
+
|
|
143
|
+
- 459b6fa72: refactor: search v1 endpoint and local-database
|
|
144
|
+
|
|
145
|
+
- refactor search `api v1` endpoint, improve performance
|
|
146
|
+
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
|
|
147
|
+
- refactor method storage class
|
|
148
|
+
- create new module `core` to reduce the ammount of modules with utilities
|
|
149
|
+
- use `undici` instead `node-fetch`
|
|
150
|
+
- use `fastify` instead `express` for functional test
|
|
151
|
+
|
|
152
|
+
### Breaking changes
|
|
153
|
+
|
|
154
|
+
- plugin storage API changes
|
|
155
|
+
- remove old search endpoint (return 404)
|
|
156
|
+
- filter local private packages at plugin level
|
|
157
|
+
|
|
158
|
+
The storage api changes for methods `get`, `add`, `remove` as promise base. The `search` methods also changes and recieves a `query` object that contains all query params from the client.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
export interface IPluginStorage<T> extends IPlugin {
|
|
162
|
+
add(name: string): Promise<void>;
|
|
163
|
+
remove(name: string): Promise<void>;
|
|
164
|
+
get(): Promise<any>;
|
|
165
|
+
init(): Promise<void>;
|
|
166
|
+
getSecret(): Promise<string>;
|
|
167
|
+
setSecret(secret: string): Promise<any>;
|
|
168
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
169
|
+
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
|
|
170
|
+
saveToken(token: Token): Promise<any>;
|
|
171
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
172
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- 9fc2e7961: feat(plugins): improve plugin loader
|
|
177
|
+
|
|
178
|
+
### Changes
|
|
179
|
+
|
|
180
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
181
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
182
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
183
|
+
- `config.plugins` plugin path validations
|
|
184
|
+
- Updated algorithm for plugin loader.
|
|
185
|
+
- improved documentation (included dev)
|
|
186
|
+
|
|
187
|
+
## Features
|
|
188
|
+
|
|
189
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
190
|
+
- Custom prefix:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
// config.yaml
|
|
194
|
+
server:
|
|
195
|
+
pluginPrefix: mycompany
|
|
196
|
+
middleware:
|
|
197
|
+
audit:
|
|
198
|
+
foo: 1
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
202
|
+
|
|
203
|
+
## Breaking Changes
|
|
204
|
+
|
|
205
|
+
### sinopia plugins
|
|
206
|
+
|
|
207
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
208
|
+
|
|
209
|
+
### plugin filter
|
|
210
|
+
|
|
211
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
212
|
+
|
|
213
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
214
|
+
|
|
215
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
// config.yaml
|
|
219
|
+
auth:
|
|
220
|
+
plugin:
|
|
221
|
+
foo: 1
|
|
222
|
+
bar: 2
|
|
223
|
+
|
|
224
|
+
export class Plugin<T> {
|
|
225
|
+
public constructor(config: T, options: PluginOptions) {
|
|
226
|
+
console.log(config);
|
|
227
|
+
// {foo:1, bar: 2}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
- 794af76c5: Remove Node 12 support
|
|
233
|
+
|
|
234
|
+
- We need move to the new `undici` and does not support Node.js 12
|
|
235
|
+
|
|
236
|
+
- 10aeb4f13: feat!: experiments config renamed to flags
|
|
237
|
+
|
|
238
|
+
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
flags: token: false;
|
|
242
|
+
search: false;
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
|
|
246
|
+
- Refactor `config` module, better types and utilities
|
|
247
|
+
|
|
248
|
+
- e367c3f1e: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
|
|
249
|
+
|
|
250
|
+
- Introduce environment variables for legacy tokens
|
|
251
|
+
|
|
252
|
+
### Code Improvements
|
|
253
|
+
|
|
254
|
+
- Add debug library for improve developer experience
|
|
255
|
+
|
|
256
|
+
### Breaking change
|
|
257
|
+
|
|
258
|
+
- The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
|
|
259
|
+
- The secret key must have 32 characters long.
|
|
260
|
+
|
|
261
|
+
### New environment variables
|
|
262
|
+
|
|
263
|
+
- `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
|
|
264
|
+
- `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
|
|
265
|
+
|
|
266
|
+
- 061bfcc8d: feat: standalone registry with no dependencies
|
|
267
|
+
|
|
268
|
+
## Usage
|
|
269
|
+
|
|
270
|
+
To install a server with no dependencies
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npm install -g @verdaccio/standalone
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
with no internet required
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
npm install -g ./tarball.tar.gz
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Bundles htpasswd and audit plugins.
|
|
283
|
+
|
|
284
|
+
### Breaking Change
|
|
285
|
+
|
|
286
|
+
It does not allow anymore the `auth` and `middleware` property at config file empty,
|
|
287
|
+
it will fallback to those plugins by default.
|
|
288
|
+
|
|
289
|
+
### Minor Changes
|
|
290
|
+
|
|
291
|
+
- 631abe1ac: feat: refactor logger
|
|
292
|
+
- ddb6a2239: feat: signature package
|
|
293
|
+
- b61f762d6: feat: add server rate limit protection to all request
|
|
294
|
+
|
|
295
|
+
To modify custom values, use the server settings property.
|
|
296
|
+
|
|
297
|
+
```markdown
|
|
298
|
+
server:
|
|
299
|
+
|
|
300
|
+
## https://www.npmjs.com/package/express-rate-limit#configuration-options
|
|
301
|
+
|
|
302
|
+
rateLimit:
|
|
303
|
+
windowMs: 1000
|
|
304
|
+
max: 10000
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The values are intended to be high, if you want to improve security of your server consider
|
|
308
|
+
using different values.
|
|
309
|
+
|
|
310
|
+
- 154b2ecd3: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
311
|
+
- aa763baec: feat: add typescript project references settings
|
|
312
|
+
|
|
313
|
+
Reading https://ebaytech.berlin/optimizing-multi-package-apps-with-typescript-project-references-d5c57a3b4440 I realized I can use project references to solve the issue to pre-compile modules on develop mode.
|
|
314
|
+
|
|
315
|
+
It allows to navigate (IDE) trough the packages without need compile the packages.
|
|
316
|
+
|
|
317
|
+
Add two `tsconfig`, one using the previous existing configuration that is able to produce declaration files (`tsconfig.build`) and a new one `tsconfig` which is enables [_projects references_](https://www.typescriptlang.org/docs/handbook/project-references.html).
|
|
318
|
+
|
|
319
|
+
- 62c24b632: feat: add passwordValidationRegex property
|
|
320
|
+
- 20c9e43ed: dist tags Implementation on Fastify
|
|
321
|
+
- c9d1af0e5: feat: async bcrypt hash
|
|
322
|
+
- 4b29d715b: chore: move improvements from v5 to v6
|
|
323
|
+
|
|
324
|
+
Migrate improvements form v5 to v6:
|
|
325
|
+
|
|
326
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
327
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
328
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
329
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
330
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
331
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
332
|
+
|
|
333
|
+
### Patch Changes
|
|
334
|
+
|
|
335
|
+
- 351aeeaa8: fix(deps): @verdaccio/utils should be a prod dep of local-storage
|
|
336
|
+
- a610ef26b: chore: add release step to private regisry on merge changeset pr
|
|
337
|
+
- 34f0f1101: Enable prerelease mode with **changesets**
|
|
338
|
+
- aeff267d9: Refactor htpasswd plugin to use the bcryptjs 'compare' api call instead of 'comparSync'. Add a new configuration value named 'slow_verify_ms' to the htpasswd plugin that when exceeded during password verification will log a warning message.
|
|
339
|
+
- 68ea21214: ESLint Warnings Fixed
|
|
340
|
+
|
|
341
|
+
Related to issue #1461
|
|
342
|
+
|
|
343
|
+
- max-len: most of the sensible max-len errors are fixed
|
|
344
|
+
- no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
|
|
345
|
+
- @typescript-eslint/no-unused-vars: same as above
|
|
346
|
+
|
|
347
|
+
- Updated dependencies [292c0a37f]
|
|
348
|
+
- Updated dependencies [a1986e098]
|
|
349
|
+
- Updated dependencies [974cd8c19]
|
|
350
|
+
- Updated dependencies [a828271d6]
|
|
351
|
+
- Updated dependencies [ef88da3b4]
|
|
352
|
+
- Updated dependencies [43f32687c]
|
|
353
|
+
- Updated dependencies [679c19c1b]
|
|
354
|
+
- Updated dependencies [a3a209b5e]
|
|
355
|
+
- Updated dependencies [459b6fa72]
|
|
356
|
+
- Updated dependencies [9fc2e7961]
|
|
357
|
+
- Updated dependencies [24b9be020]
|
|
358
|
+
- Updated dependencies [794af76c5]
|
|
359
|
+
- Updated dependencies [e75c0a3b9]
|
|
360
|
+
- Updated dependencies [351aeeaa8]
|
|
361
|
+
- Updated dependencies [10aeb4f13]
|
|
362
|
+
- Updated dependencies [631abe1ac]
|
|
363
|
+
- Updated dependencies [9718e0330]
|
|
364
|
+
- Updated dependencies [1b217fd34]
|
|
365
|
+
- Updated dependencies [e367c3f1e]
|
|
366
|
+
- Updated dependencies [a1da11308]
|
|
367
|
+
- Updated dependencies [d167f92e1]
|
|
368
|
+
- Updated dependencies [d2c65da9c]
|
|
369
|
+
- Updated dependencies [00d1d2a17]
|
|
370
|
+
- Updated dependencies [1810ed0d8]
|
|
371
|
+
- Updated dependencies [a610ef26b]
|
|
372
|
+
- Updated dependencies [ddb6a2239]
|
|
373
|
+
- Updated dependencies [e54ec4b5d]
|
|
374
|
+
- Updated dependencies [31d661c7b]
|
|
375
|
+
- Updated dependencies [648575aa4]
|
|
376
|
+
- Updated dependencies [b61f762d6]
|
|
377
|
+
- Updated dependencies [d43894e8f]
|
|
378
|
+
- Updated dependencies [154b2ecd3]
|
|
379
|
+
- Updated dependencies [061bfcc8d]
|
|
380
|
+
- Updated dependencies [aa763baec]
|
|
381
|
+
- Updated dependencies [378e907d5]
|
|
382
|
+
- Updated dependencies [16e38df8a]
|
|
383
|
+
- Updated dependencies [34f0f1101]
|
|
384
|
+
- Updated dependencies [df0da3d69]
|
|
385
|
+
- Updated dependencies [82cb0f2bf]
|
|
386
|
+
- Updated dependencies [dc571aabd]
|
|
387
|
+
- Updated dependencies [b78f35257]
|
|
388
|
+
- Updated dependencies [f859d2b1a]
|
|
389
|
+
- Updated dependencies [2c594910d]
|
|
390
|
+
- Updated dependencies [6c1eb021b]
|
|
391
|
+
- Updated dependencies [62c24b632]
|
|
392
|
+
- Updated dependencies [09753cc1f]
|
|
393
|
+
- Updated dependencies [0a6412ca9]
|
|
394
|
+
- Updated dependencies [d08fe29d9]
|
|
395
|
+
- Updated dependencies [5167bb528]
|
|
396
|
+
- Updated dependencies [f86c31ed0]
|
|
397
|
+
- Updated dependencies [c8a040e69]
|
|
398
|
+
- Updated dependencies [65f88b826]
|
|
399
|
+
- Updated dependencies [aeff267d9]
|
|
400
|
+
- Updated dependencies [b3e8438f6]
|
|
401
|
+
- Updated dependencies [c9d1af0e5]
|
|
402
|
+
- Updated dependencies [730b5d8cc]
|
|
403
|
+
- Updated dependencies [4b29d715b]
|
|
404
|
+
- Updated dependencies [b13a3fefd]
|
|
405
|
+
- Updated dependencies [68ea21214]
|
|
406
|
+
- Updated dependencies [8f43bf17d]
|
|
407
|
+
- Updated dependencies [45c03819e]
|
|
408
|
+
- Updated dependencies [b849128de]
|
|
409
|
+
- @verdaccio/config@6.0.0
|
|
410
|
+
- @verdaccio/core@6.0.0
|
|
411
|
+
- @verdaccio/loaders@6.0.0
|
|
412
|
+
- @verdaccio/logger@6.0.0
|
|
413
|
+
- verdaccio-htpasswd@11.0.0
|
|
414
|
+
- @verdaccio/utils@6.0.0
|
|
415
|
+
- @verdaccio/signature@6.0.0
|
|
416
|
+
|
|
3
417
|
## 6.0.0-6-next.55
|
|
4
418
|
|
|
5
419
|
### Patch Changes
|
package/LICENSE
CHANGED
package/build/auth.d.ts
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
|
2
1
|
import { VerdaccioError, pluginUtils } from '@verdaccio/core';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
aesEncrypt(buf: string): string | void;
|
|
7
|
-
}
|
|
8
|
-
export interface AESPayload {
|
|
9
|
-
user: string;
|
|
10
|
-
password: string;
|
|
11
|
-
}
|
|
12
|
-
export interface IAuthMiddleware {
|
|
13
|
-
apiJWTmiddleware(): $NextFunctionVer;
|
|
14
|
-
webUIJWTmiddleware(): $NextFunctionVer;
|
|
15
|
-
}
|
|
16
|
-
export type $RequestExtend = Request & {
|
|
17
|
-
remote_user?: any;
|
|
18
|
-
log: Logger;
|
|
19
|
-
};
|
|
20
|
-
export type $ResponseExtend = Response & {
|
|
21
|
-
cookies?: any;
|
|
22
|
-
};
|
|
23
|
-
export type $NextFunctionVer = NextFunction & any;
|
|
2
|
+
import '@verdaccio/core';
|
|
3
|
+
import { Callback, Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';
|
|
4
|
+
import { $RequestExtend, $ResponseExtend, IAuthMiddleware, NextFunction, TokenEncryption } from './types';
|
|
24
5
|
declare class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
|
|
25
6
|
config: Config;
|
|
26
7
|
secret: string;
|
|
@@ -43,14 +24,14 @@ declare class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBas
|
|
|
43
24
|
* Allow user to publish a package.
|
|
44
25
|
*/
|
|
45
26
|
allow_publish({ packageName, packageVersion }: pluginUtils.AuthPluginPackage, user: RemoteUser, callback: Callback): void;
|
|
46
|
-
apiJWTmiddleware():
|
|
47
|
-
private
|
|
48
|
-
private
|
|
27
|
+
apiJWTmiddleware(): any;
|
|
28
|
+
private handleJWTAPIMiddleware;
|
|
29
|
+
private handleAESMiddleware;
|
|
49
30
|
private _isRemoteUserValid;
|
|
50
31
|
/**
|
|
51
32
|
* JWT middleware for WebUI
|
|
52
33
|
*/
|
|
53
|
-
webUIJWTmiddleware():
|
|
34
|
+
webUIJWTmiddleware(): (req: $RequestExtend, res: $ResponseExtend, _next: NextFunction) => void;
|
|
54
35
|
jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): Promise<string>;
|
|
55
36
|
/**
|
|
56
37
|
* Encrypt a string.
|
package/build/auth.js
CHANGED
|
@@ -16,9 +16,6 @@ var _utils = require("@verdaccio/utils");
|
|
|
16
16
|
var _utils2 = require("./utils");
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
const debug = (0, _debug.default)('verdaccio:auth');
|
|
19
|
-
|
|
20
|
-
// remove
|
|
21
|
-
|
|
22
19
|
class Auth {
|
|
23
20
|
constructor(config) {
|
|
24
21
|
this.config = config;
|
|
@@ -146,23 +143,29 @@ class Auth {
|
|
|
146
143
|
const plugins = this.plugins.slice(0);
|
|
147
144
|
debug('add user %o', user);
|
|
148
145
|
(function next() {
|
|
146
|
+
let method = 'adduser';
|
|
149
147
|
const plugin = plugins.shift();
|
|
150
|
-
|
|
148
|
+
// @ts-expect-error future major (7.x) should remove this section
|
|
149
|
+
if (typeof plugin.adduser === 'undefined' && typeof plugin.add_user === 'function') {
|
|
150
|
+
method = 'add_user';
|
|
151
|
+
_core.warningUtils.emit(_core.warningUtils.Codes.VERWAR006);
|
|
152
|
+
}
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
if (typeof plugin[method] !== 'function') {
|
|
151
155
|
next();
|
|
152
156
|
} else {
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
plugin.adduser(user, password, function (err, ok) {
|
|
157
|
+
// TODO: replace by adduser whenever add_user deprecation method has been removed
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
plugin[method](user, password, function (err, ok) {
|
|
158
160
|
if (err) {
|
|
159
|
-
debug('the user
|
|
161
|
+
debug('the user %o could not being added. Error: %o', user, err === null || err === void 0 ? void 0 : err.message);
|
|
160
162
|
return cb(err);
|
|
161
163
|
}
|
|
162
164
|
if (ok) {
|
|
163
165
|
debug('the user %o has been added', user);
|
|
164
166
|
return self.authenticate(user, password, cb);
|
|
165
167
|
}
|
|
168
|
+
debug('user could not be added, skip to next auth plugin');
|
|
166
169
|
next();
|
|
167
170
|
});
|
|
168
171
|
}
|
|
@@ -201,7 +204,6 @@ class Auth {
|
|
|
201
204
|
});
|
|
202
205
|
})();
|
|
203
206
|
}
|
|
204
|
-
|
|
205
207
|
allow_unpublish({
|
|
206
208
|
packageName,
|
|
207
209
|
packageVersion
|
|
@@ -212,11 +214,10 @@ class Auth {
|
|
|
212
214
|
}, (0, _utils.getMatchedPackagesSpec)(packageName, this.config.packages));
|
|
213
215
|
debug('allow unpublish for %o', packageName);
|
|
214
216
|
for (const plugin of this.plugins) {
|
|
215
|
-
if (
|
|
217
|
+
if (typeof (plugin === null || plugin === void 0 ? void 0 : plugin.allow_unpublish) !== 'function') {
|
|
216
218
|
debug('allow unpublish for %o plugin does not implement allow_unpublish', packageName);
|
|
217
219
|
continue;
|
|
218
220
|
} else {
|
|
219
|
-
// @ts-ignore
|
|
220
221
|
plugin.allow_unpublish(user, pkg, (err, ok) => {
|
|
221
222
|
if (err) {
|
|
222
223
|
debug('forbidden publish for %o, it will fallback on unpublish permissions', packageName);
|
|
@@ -224,9 +225,10 @@ class Auth {
|
|
|
224
225
|
}
|
|
225
226
|
if (_lodash.default.isNil(ok) === true) {
|
|
226
227
|
debug('bypass unpublish for %o, publish will handle the access', packageName);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
return this.allow_publish({
|
|
229
|
+
packageName,
|
|
230
|
+
packageVersion
|
|
231
|
+
}, user, callback);
|
|
230
232
|
}
|
|
231
233
|
if (ok) {
|
|
232
234
|
debug('allowed unpublish for %o', packageName);
|
|
@@ -270,7 +272,6 @@ class Auth {
|
|
|
270
272
|
});
|
|
271
273
|
})();
|
|
272
274
|
}
|
|
273
|
-
|
|
274
275
|
apiJWTmiddleware() {
|
|
275
276
|
debug('jwt middleware');
|
|
276
277
|
const plugins = this.plugins.slice(0);
|
|
@@ -283,8 +284,6 @@ class Auth {
|
|
|
283
284
|
return plugin.apiJWTmiddleware(helpers);
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
-
// @ts-ignore
|
|
288
287
|
return (req, res, _next) => {
|
|
289
288
|
req.pause();
|
|
290
289
|
const next = function (err) {
|
|
@@ -298,10 +297,12 @@ class Auth {
|
|
|
298
297
|
}
|
|
299
298
|
return _next();
|
|
300
299
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
300
|
+
|
|
301
|
+
// FUTURE: disabled, not removed yet but seems unreacable code
|
|
302
|
+
// if (this._isRemoteUserValid(req.remote_user)) {
|
|
303
|
+
// debug('jwt has a valid authentication header');
|
|
304
|
+
// return next();
|
|
305
|
+
// }
|
|
305
306
|
|
|
306
307
|
// in case auth header does not exist we return anonymous function
|
|
307
308
|
const remoteUser = (0, _config.createAnonymousRemoteUser)();
|
|
@@ -324,14 +325,14 @@ class Auth {
|
|
|
324
325
|
} = this.config;
|
|
325
326
|
if ((0, _utils2.isAESLegacy)(security)) {
|
|
326
327
|
debug('api middleware using legacy auth token');
|
|
327
|
-
this.
|
|
328
|
+
this.handleAESMiddleware(req, security, secret, authorization, next);
|
|
328
329
|
} else {
|
|
329
330
|
debug('api middleware using JWT auth token');
|
|
330
|
-
this.
|
|
331
|
+
this.handleJWTAPIMiddleware(req, security, secret, authorization, next);
|
|
331
332
|
}
|
|
332
333
|
};
|
|
333
334
|
}
|
|
334
|
-
|
|
335
|
+
handleJWTAPIMiddleware(req, security, secret, authorization, next) {
|
|
335
336
|
debug('handle JWT api middleware');
|
|
336
337
|
const {
|
|
337
338
|
scheme,
|
|
@@ -372,11 +373,12 @@ class Auth {
|
|
|
372
373
|
}
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
|
-
|
|
376
|
+
handleAESMiddleware(req, security, secret, authorization, next) {
|
|
377
|
+
var _this$config2;
|
|
376
378
|
debug('handle legacy api middleware');
|
|
377
379
|
debug('api middleware secret %o', typeof secret === 'string');
|
|
378
380
|
debug('api middleware authorization %o', typeof authorization === 'string');
|
|
379
|
-
const credentials = (0, _utils2.getMiddlewareCredentials)(security, secret, authorization);
|
|
381
|
+
const credentials = (0, _utils2.getMiddlewareCredentials)(security, secret, authorization, (_this$config2 = this.config) === null || _this$config2 === void 0 ? void 0 : _this$config2.getEnhancedLegacySignature());
|
|
380
382
|
debug('api middleware credentials %o', credentials === null || credentials === void 0 ? void 0 : credentials.name);
|
|
381
383
|
if (credentials) {
|
|
382
384
|
const {
|
|
@@ -409,7 +411,6 @@ class Auth {
|
|
|
409
411
|
* JWT middleware for WebUI
|
|
410
412
|
*/
|
|
411
413
|
webUIJWTmiddleware() {
|
|
412
|
-
// @ts-ignore
|
|
413
414
|
return (req, res, _next) => {
|
|
414
415
|
if (this._isRemoteUserValid(req.remote_user)) {
|
|
415
416
|
return _next();
|
|
@@ -418,7 +419,7 @@ class Auth {
|
|
|
418
419
|
const next = err => {
|
|
419
420
|
req.resume();
|
|
420
421
|
if (err) {
|
|
421
|
-
|
|
422
|
+
req.remote_user.error = err.message;
|
|
422
423
|
res.status(err.statusCode).send(err.message);
|
|
423
424
|
}
|
|
424
425
|
return _next();
|
|
@@ -476,7 +477,18 @@ class Auth {
|
|
|
476
477
|
* Encrypt a string.
|
|
477
478
|
*/
|
|
478
479
|
aesEncrypt(value) {
|
|
479
|
-
|
|
480
|
+
var _this$config3;
|
|
481
|
+
// enhancedLegacySignature enables modern aes192 algorithm signature
|
|
482
|
+
if ((_this$config3 = this.config) !== null && _this$config3 !== void 0 && _this$config3.getEnhancedLegacySignature()) {
|
|
483
|
+
debug('signing with enhaced aes legacy');
|
|
484
|
+
const token = (0, _signature.aesEncrypt)(value, this.secret);
|
|
485
|
+
return token;
|
|
486
|
+
} else {
|
|
487
|
+
debug('signing with enhaced aes deprecated legacy');
|
|
488
|
+
// deprecated aes (legacy) signature, only must be used for legacy version
|
|
489
|
+
const token = (0, _signature.aesEncryptDeprecated)(Buffer.from(value), this.secret).toString('base64');
|
|
490
|
+
return token;
|
|
491
|
+
}
|
|
480
492
|
}
|
|
481
493
|
}
|
|
482
494
|
exports.Auth = Auth;
|