verdaccio-auth-memory 10.1.0 → 11.0.0-6-next.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/.babelrc +3 -0
- package/CHANGELOG.md +298 -0
- package/README.md +30 -27
- package/{lib → build}/Memory.d.ts +2 -12
- package/build/Memory.js +151 -0
- package/build/Memory.js.map +1 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/build/types/index.d.ts +12 -0
- package/build/types/index.js +6 -0
- package/build/types/index.js.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +52 -48
- package/src/Memory.ts +144 -0
- package/src/index.ts +5 -0
- package/src/types/index.ts +15 -0
- package/test/index.spec.ts +253 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +14 -0
- package/lib/Memory.js +0 -184
- package/lib/Memory.js.map +0 -1
package/.babelrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## 11.0.0-6-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [24b9be02]
|
|
8
|
+
- @verdaccio/core@6.0.0-6-next.4
|
|
9
|
+
|
|
10
|
+
## 11.0.0-6-next.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [6c1eb021]
|
|
15
|
+
- @verdaccio/core@6.0.0-6-next.3
|
|
16
|
+
|
|
17
|
+
## 11.0.0-6-next.5
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- 794af76c: Remove Node 12 support
|
|
22
|
+
|
|
23
|
+
- We need move to the new `undici` and does not support Node.js 12
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [794af76c]
|
|
32
|
+
- Updated dependencies [154b2ecd]
|
|
33
|
+
- @verdaccio/core@6.0.0-6-next.2
|
|
34
|
+
|
|
35
|
+
## 11.0.0-6-next.4
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [459b6fa7]
|
|
40
|
+
- @verdaccio/commons-api@11.0.0-6-next.4
|
|
41
|
+
|
|
42
|
+
## 10.0.0-alpha.3
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- fecbb9be: chore: add release step to private regisry on merge changeset pr
|
|
47
|
+
- Updated dependencies [fecbb9be]
|
|
48
|
+
- @verdaccio/commons-api@10.0.0-alpha.3
|
|
49
|
+
|
|
50
|
+
## 10.0.0-alpha.2
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- 54c58d1e: feat: add server rate limit protection to all request
|
|
55
|
+
|
|
56
|
+
To modify custom values, use the server settings property.
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
server:
|
|
60
|
+
|
|
61
|
+
## https://www.npmjs.com/package/express-rate-limit#configuration-options
|
|
62
|
+
|
|
63
|
+
rateLimit:
|
|
64
|
+
windowMs: 1000
|
|
65
|
+
max: 10000
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The values are intended to be high, if you want to improve security of your server consider
|
|
69
|
+
using different values.
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [54c58d1e]
|
|
74
|
+
- @verdaccio/commons-api@10.0.0-alpha.2
|
|
75
|
+
|
|
76
|
+
## 10.0.0-alpha.1
|
|
77
|
+
|
|
78
|
+
### Major Changes
|
|
79
|
+
|
|
80
|
+
- d87fa026: feat!: experiments config renamed to flags
|
|
81
|
+
|
|
82
|
+
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
flags: token: false;
|
|
86
|
+
search: false;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
|
|
90
|
+
- Refactor `config` module, better types and utilities
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [d87fa026]
|
|
95
|
+
- Updated dependencies [da1ee9c8]
|
|
96
|
+
- Updated dependencies [26b494cb]
|
|
97
|
+
- Updated dependencies [b57b4338]
|
|
98
|
+
- Updated dependencies [31af0164]
|
|
99
|
+
- @verdaccio/commons-api@10.0.0-alpha.1
|
|
100
|
+
|
|
101
|
+
All notable changes to this project will be documented in this file.
|
|
102
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
103
|
+
|
|
104
|
+
## [9.7.2](https://github.com/verdaccio/monorepo/compare/v9.7.1...v9.7.2) (2020-07-20)
|
|
105
|
+
|
|
106
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
107
|
+
|
|
108
|
+
## [9.7.1](https://github.com/verdaccio/monorepo/compare/v9.7.0...v9.7.1) (2020-07-10)
|
|
109
|
+
|
|
110
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
111
|
+
|
|
112
|
+
# [9.7.0](https://github.com/verdaccio/monorepo/compare/v9.6.1...v9.7.0) (2020-06-24)
|
|
113
|
+
|
|
114
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
115
|
+
|
|
116
|
+
## [9.6.1](https://github.com/verdaccio/monorepo/compare/v9.6.0...v9.6.1) (2020-06-07)
|
|
117
|
+
|
|
118
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
119
|
+
|
|
120
|
+
# [9.5.0](https://github.com/verdaccio/monorepo/compare/v9.4.1...v9.5.0) (2020-05-02)
|
|
121
|
+
|
|
122
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
123
|
+
|
|
124
|
+
# [9.4.0](https://github.com/verdaccio/monorepo/compare/v9.3.4...v9.4.0) (2020-03-21)
|
|
125
|
+
|
|
126
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
127
|
+
|
|
128
|
+
## [9.3.2](https://github.com/verdaccio/monorepo/compare/v9.3.1...v9.3.2) (2020-03-08)
|
|
129
|
+
|
|
130
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
131
|
+
|
|
132
|
+
## [9.3.1](https://github.com/verdaccio/monorepo/compare/v9.3.0...v9.3.1) (2020-02-23)
|
|
133
|
+
|
|
134
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
135
|
+
|
|
136
|
+
# [9.3.0](https://github.com/verdaccio/monorepo/compare/v9.2.0...v9.3.0) (2020-01-29)
|
|
137
|
+
|
|
138
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
139
|
+
|
|
140
|
+
# [9.0.0](https://github.com/verdaccio/monorepo/compare/v8.5.3...v9.0.0) (2020-01-07)
|
|
141
|
+
|
|
142
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
143
|
+
|
|
144
|
+
## [8.5.2](https://github.com/verdaccio/monorepo/compare/v8.5.1...v8.5.2) (2019-12-25)
|
|
145
|
+
|
|
146
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
147
|
+
|
|
148
|
+
## [8.5.1](https://github.com/verdaccio/monorepo/compare/v8.5.0...v8.5.1) (2019-12-24)
|
|
149
|
+
|
|
150
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
151
|
+
|
|
152
|
+
# [8.5.0](https://github.com/verdaccio/monorepo/compare/v8.4.2...v8.5.0) (2019-12-22)
|
|
153
|
+
|
|
154
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
155
|
+
|
|
156
|
+
## [8.4.2](https://github.com/verdaccio/monorepo/compare/v8.4.1...v8.4.2) (2019-11-23)
|
|
157
|
+
|
|
158
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
159
|
+
|
|
160
|
+
## [8.4.1](https://github.com/verdaccio/monorepo/compare/v8.4.0...v8.4.1) (2019-11-22)
|
|
161
|
+
|
|
162
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
163
|
+
|
|
164
|
+
# [8.4.0](https://github.com/verdaccio/monorepo/compare/v8.3.0...v8.4.0) (2019-11-22)
|
|
165
|
+
|
|
166
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
167
|
+
|
|
168
|
+
# [8.3.0](https://github.com/verdaccio/monorepo/compare/v8.2.0...v8.3.0) (2019-10-27)
|
|
169
|
+
|
|
170
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
171
|
+
|
|
172
|
+
# [8.2.0](https://github.com/verdaccio/monorepo/compare/v8.2.0-next.0...v8.2.0) (2019-10-23)
|
|
173
|
+
|
|
174
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
175
|
+
|
|
176
|
+
# [8.2.0-next.0](https://github.com/verdaccio/monorepo/compare/v8.1.4...v8.2.0-next.0) (2019-10-08)
|
|
177
|
+
|
|
178
|
+
### Bug Fixes
|
|
179
|
+
|
|
180
|
+
- fixed lint errors ([5e677f7](https://github.com/verdaccio/monorepo/commit/5e677f7))
|
|
181
|
+
|
|
182
|
+
## [8.1.2](https://github.com/verdaccio/monorepo/compare/v8.1.1...v8.1.2) (2019-09-29)
|
|
183
|
+
|
|
184
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
185
|
+
|
|
186
|
+
## [8.1.1](https://github.com/verdaccio/monorepo/compare/v8.1.0...v8.1.1) (2019-09-26)
|
|
187
|
+
|
|
188
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
189
|
+
|
|
190
|
+
# [8.1.0](https://github.com/verdaccio/monorepo/compare/v8.0.1-next.1...v8.1.0) (2019-09-07)
|
|
191
|
+
|
|
192
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
193
|
+
|
|
194
|
+
## [8.0.1-next.1](https://github.com/verdaccio/monorepo/compare/v8.0.1-next.0...v8.0.1-next.1) (2019-08-29)
|
|
195
|
+
|
|
196
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
197
|
+
|
|
198
|
+
## [8.0.1-next.0](https://github.com/verdaccio/monorepo/compare/v8.0.0...v8.0.1-next.0) (2019-08-29)
|
|
199
|
+
|
|
200
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
201
|
+
|
|
202
|
+
# [8.0.0](https://github.com/verdaccio/monorepo/compare/v8.0.0-next.4...v8.0.0) (2019-08-22)
|
|
203
|
+
|
|
204
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
205
|
+
|
|
206
|
+
# [8.0.0-next.4](https://github.com/verdaccio/monorepo/compare/v8.0.0-next.3...v8.0.0-next.4) (2019-08-18)
|
|
207
|
+
|
|
208
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
209
|
+
|
|
210
|
+
# [8.0.0-next.2](https://github.com/verdaccio/monorepo/compare/v8.0.0-next.1...v8.0.0-next.2) (2019-08-03)
|
|
211
|
+
|
|
212
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
213
|
+
|
|
214
|
+
# [8.0.0-next.1](https://github.com/verdaccio/monorepo/compare/v8.0.0-next.0...v8.0.0-next.1) (2019-08-01)
|
|
215
|
+
|
|
216
|
+
**Note:** Version bump only for package verdaccio-auth-memory
|
|
217
|
+
|
|
218
|
+
# [8.0.0-next.0](https://github.com/verdaccio/monorepo/compare/v2.0.0...v8.0.0-next.0) (2019-08-01)
|
|
219
|
+
|
|
220
|
+
### Bug Fixes
|
|
221
|
+
|
|
222
|
+
- main file is correct routed ([245b115](https://github.com/verdaccio/monorepo/commit/245b115))
|
|
223
|
+
- remove source maps ([6ca4895](https://github.com/verdaccio/monorepo/commit/6ca4895))
|
|
224
|
+
- restore error messages ([5d241b6](https://github.com/verdaccio/monorepo/commit/5d241b6))
|
|
225
|
+
|
|
226
|
+
### Features
|
|
227
|
+
|
|
228
|
+
- add logging output for each action ([66f183c](https://github.com/verdaccio/monorepo/commit/66f183c))
|
|
229
|
+
- change password ([de0a341](https://github.com/verdaccio/monorepo/commit/de0a341))
|
|
230
|
+
- migrate to typescript BREAKING CHANGE: new compiler might bring issues ([13ebde2](https://github.com/verdaccio/monorepo/commit/13ebde2))
|
|
231
|
+
- **config:** allow set users ([e5326fd](https://github.com/verdaccio/monorepo/commit/e5326fd))
|
|
232
|
+
|
|
233
|
+
# Changelog
|
|
234
|
+
|
|
235
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
236
|
+
|
|
237
|
+
### [1.1.5](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.1.4...v1.1.5) (2019-07-15)
|
|
238
|
+
|
|
239
|
+
### Bug Fixes
|
|
240
|
+
|
|
241
|
+
- restore error messages ([094da45](https://github.com/verdaccio/verdaccio-auth-memory/commit/094da45))
|
|
242
|
+
|
|
243
|
+
### [1.1.4](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.1.3...v1.1.4) (2019-07-15)
|
|
244
|
+
|
|
245
|
+
### Tests
|
|
246
|
+
|
|
247
|
+
- fix wrong string match ([d4d2e81](https://github.com/verdaccio/verdaccio-auth-memory/commit/d4d2e81))
|
|
248
|
+
|
|
249
|
+
### [1.1.3](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.1.2...v1.1.3) (2019-07-15)
|
|
250
|
+
|
|
251
|
+
### Build System
|
|
252
|
+
|
|
253
|
+
- update @verdaccio/commons-api@0.1.2 ([55f39a4](https://github.com/verdaccio/verdaccio-auth-memory/commit/55f39a4))
|
|
254
|
+
|
|
255
|
+
### [1.1.2](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.1.1...v1.1.2) (2019-07-15)
|
|
256
|
+
|
|
257
|
+
### Build System
|
|
258
|
+
|
|
259
|
+
- build step before publish ([468ddbc](https://github.com/verdaccio/verdaccio-auth-memory/commit/468ddbc))
|
|
260
|
+
|
|
261
|
+
### [1.1.1](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.1.0...v1.1.1) (2019-07-12)
|
|
262
|
+
|
|
263
|
+
### Build System
|
|
264
|
+
|
|
265
|
+
- fix unit test ([6d7b383](https://github.com/verdaccio/verdaccio-auth-memory/commit/6d7b383))
|
|
266
|
+
|
|
267
|
+
## [1.1.0](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.0.2...v1.1.0) (2019-07-12)
|
|
268
|
+
|
|
269
|
+
### Features
|
|
270
|
+
|
|
271
|
+
- add logging output for each action ([099f9aa](https://github.com/verdaccio/verdaccio-auth-memory/commit/099f9aa))
|
|
272
|
+
|
|
273
|
+
### [1.0.2](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.0.1...v1.0.2) (2019-07-12)
|
|
274
|
+
|
|
275
|
+
### Bug Fixes
|
|
276
|
+
|
|
277
|
+
- main file is correct routed ([722a615](https://github.com/verdaccio/verdaccio-auth-memory/commit/722a615))
|
|
278
|
+
|
|
279
|
+
### [1.0.1](https://github.com/verdaccio/verdaccio-auth-memory/compare/v1.0.0...v1.0.1) (2019-07-12)
|
|
280
|
+
|
|
281
|
+
### Bug Fixes
|
|
282
|
+
|
|
283
|
+
- remove source maps ([6f29a06](https://github.com/verdaccio/verdaccio-auth-memory/commit/6f29a06))
|
|
284
|
+
|
|
285
|
+
## [1.0.0](https://github.com/verdaccio/verdaccio-auth-memory/compare/v0.0.4...v1.0.0) (2019-07-12)
|
|
286
|
+
|
|
287
|
+
### Build System
|
|
288
|
+
|
|
289
|
+
- add coverage build script ([4f25313](https://github.com/verdaccio/verdaccio-auth-memory/commit/4f25313))
|
|
290
|
+
|
|
291
|
+
### Features
|
|
292
|
+
|
|
293
|
+
- change password ([19d9838](https://github.com/verdaccio/verdaccio-auth-memory/commit/19d9838))
|
|
294
|
+
- migrate to typescript ([4c3b144](https://github.com/verdaccio/verdaccio-auth-memory/commit/4c3b144))
|
|
295
|
+
|
|
296
|
+
### BREAKING CHANGES
|
|
297
|
+
|
|
298
|
+
- new compiler might bring issues
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# verdaccio-auth-memory
|
|
2
|
+
|
|
2
3
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fverdaccio%2Fverdaccio-auth-memory?ref=badge_shield)
|
|
3
4
|
[](https://circleci.com/gh/ayusharma/verdaccio-auth-memory)
|
|
4
5
|
[](https://codecov.io/gh/verdaccio/verdaccio-auth-memory)
|
|
5
6
|
|
|
6
|
-
|
|
7
7
|
This verdaccio auth plugin keeps the users in a memory plain object.
|
|
8
8
|
This means all sessions and users will disappear when you restart the verdaccio server.
|
|
9
9
|
|
|
@@ -44,46 +44,49 @@ plugin(config, appConfig);
|
|
|
44
44
|
|
|
45
45
|
Where:
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
- config - module's own config
|
|
48
|
+
- appOptions - collection of different internal verdaccio objects
|
|
49
|
+
- appOptions.config - main config
|
|
50
|
+
- appOptions.logger - logger
|
|
51
51
|
|
|
52
52
|
This should export four functions:
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
- `adduser(user, password, cb)` Add new users
|
|
55
|
+
|
|
56
|
+
It should respond with:
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- `cb(null, true)` in case user registered successfully
|
|
58
|
+
- `cb(err)` in case of an error (error will be returned to user)
|
|
59
|
+
- `cb(null, false)` in case registration is disabled (next auth plugin will be executed)
|
|
60
|
+
- `cb(null, true)` in case user registered successfully
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
It's useful to set `err.status` property to set http status code (e.g. `err.status = 403`).
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
- `authenticate(user, password, cb)` Authenticate the user
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
- `cb(err)` in case of a fatal error (error will be returned to user, keep those rare)
|
|
67
|
-
- `cb(null, false)` in case user not authenticated (next auth plugin will be executed)
|
|
68
|
-
- `cb(null, [groups])` in case user is authenticated
|
|
66
|
+
It should respond with:
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
- `cb(err)` in case of a fatal error (error will be returned to user, keep those rare)
|
|
69
|
+
- `cb(null, false)` in case user not authenticated (next auth plugin will be executed)
|
|
70
|
+
- `cb(null, [groups])` in case user is authenticated
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Groups is an array of all users/usergroups this user has access to. You should probably include username itself here.
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
- `cb(err)` in case of a fatal error (error will be returned to user, keep those rare)
|
|
76
|
-
- `cb(null, false)` in case user not allowed to access (next auth plugin will be executed)
|
|
77
|
-
- `cb(null, true)` in case user is allowed to access
|
|
74
|
+
- `allow_access(user, pkg, cb)` Check whether the user has permissions to access a resource (package)
|
|
78
75
|
|
|
79
|
-
|
|
76
|
+
It should respond with:
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- `cb(null, true)` in case user is allowed to publish
|
|
78
|
+
- `cb(err)` in case of a fatal error (error will be returned to user, keep those rare)
|
|
79
|
+
- `cb(null, false)` in case user not allowed to access (next auth plugin will be executed)
|
|
80
|
+
- `cb(null, true)` in case user is allowed to access
|
|
85
81
|
|
|
82
|
+
- `allow_publish(user, pkg, cb)` Check whether the user has permissions to publish a resource (package)
|
|
86
83
|
|
|
84
|
+
It should respond with:
|
|
85
|
+
|
|
86
|
+
- `cb(err)` in case of a fatal error (error will be returned to user, keep those rare)
|
|
87
|
+
- `cb(null, false)` in case user not allowed to publish (next auth plugin will be executed)
|
|
88
|
+
- `cb(null, true)` in case user is allowed to publish
|
|
87
89
|
|
|
88
90
|
## License
|
|
91
|
+
|
|
89
92
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fverdaccio%2Fverdaccio-auth-memory?ref=badge_large)
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
password: string;
|
|
5
|
-
}
|
|
6
|
-
export interface Users {
|
|
7
|
-
[key: string]: UserMemory;
|
|
8
|
-
}
|
|
9
|
-
export interface VerdaccioMemoryConfig extends Config {
|
|
10
|
-
max_users?: number;
|
|
11
|
-
users: Users;
|
|
12
|
-
}
|
|
1
|
+
import { Callback, IPluginAuth, Logger, PackageAccess, PluginOptions, RemoteUser } from '@verdaccio/types';
|
|
2
|
+
import { Users, VerdaccioMemoryConfig } from './types';
|
|
13
3
|
export default class Memory implements IPluginAuth<VerdaccioMemoryConfig> {
|
|
14
4
|
_logger: Logger;
|
|
15
5
|
_users: Users;
|
package/build/Memory.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
+
|
|
10
|
+
var _core = require("@verdaccio/core");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const debug = (0, _debug.default)('verdaccio:plugin:auth:memory:user');
|
|
15
|
+
|
|
16
|
+
class Memory {
|
|
17
|
+
constructor(config, appOptions) {
|
|
18
|
+
this._users = config.users || {};
|
|
19
|
+
this._config = config;
|
|
20
|
+
this._logger = appOptions.logger;
|
|
21
|
+
this._app_config = appOptions.config;
|
|
22
|
+
debug('initialized');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
authenticate(user, password, done) {
|
|
26
|
+
debug('authenticate %o:%o', user, password);
|
|
27
|
+
const userCredentials = this._users[user];
|
|
28
|
+
|
|
29
|
+
if (!userCredentials) {
|
|
30
|
+
debug('user %o does not exist', user);
|
|
31
|
+
return done(null, false);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (password !== userCredentials.password) {
|
|
35
|
+
const err = _core.errorUtils.getUnauthorized(_core.API_ERROR.BAD_USERNAME_PASSWORD);
|
|
36
|
+
|
|
37
|
+
debug('password invalid for: %o', user);
|
|
38
|
+
return done(err);
|
|
39
|
+
} // authentication succeeded!
|
|
40
|
+
// return all usergroups this user has access to;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
debug('authentication succeed for %o', user);
|
|
44
|
+
return done(null, [user]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
adduser(user, password, done) {
|
|
48
|
+
if (this._users[user]) {
|
|
49
|
+
debug('user %o already exist', user);
|
|
50
|
+
return done(null, true);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (this._app_config.max_users) {
|
|
54
|
+
if (Object.keys(this._users).length >= this._app_config.max_users) {
|
|
55
|
+
const err = _core.errorUtils.getConflict(_core.API_ERROR.MAX_USERS_REACHED);
|
|
56
|
+
|
|
57
|
+
debug(_core.API_ERROR.MAX_USERS_REACHED);
|
|
58
|
+
return done(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this._users[user] = {
|
|
63
|
+
name: user,
|
|
64
|
+
password: password
|
|
65
|
+
};
|
|
66
|
+
debug('user added succeeded for %o', user);
|
|
67
|
+
done(null, user);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
changePassword(username, password, newPassword, cb) {
|
|
71
|
+
const user = this._users[username];
|
|
72
|
+
debug('init change password for %o', user === null || user === void 0 ? void 0 : user.name);
|
|
73
|
+
|
|
74
|
+
if (user && user.password === password) {
|
|
75
|
+
user.password = newPassword;
|
|
76
|
+
this._users[username] = user;
|
|
77
|
+
debug('user changed password succeeded for %o', user === null || user === void 0 ? void 0 : user.name);
|
|
78
|
+
cb(null, user);
|
|
79
|
+
} else {
|
|
80
|
+
const err = _core.errorUtils.getNotFound('user not found');
|
|
81
|
+
|
|
82
|
+
this._logger.debug({
|
|
83
|
+
user: username
|
|
84
|
+
}, 'change password user @{user} not found');
|
|
85
|
+
|
|
86
|
+
debug('change password user for %o not found', user === null || user === void 0 ? void 0 : user.name);
|
|
87
|
+
return cb(err);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
allow_access(user, pkg, cb) {
|
|
92
|
+
var _pkg$access, _pkg$access2, _pkg$access3, _pkg$access4;
|
|
93
|
+
|
|
94
|
+
debug('allow access for %o', user);
|
|
95
|
+
|
|
96
|
+
if (pkg !== null && pkg !== void 0 && (_pkg$access = pkg.access) !== null && _pkg$access !== void 0 && _pkg$access.includes('$all') || pkg !== null && pkg !== void 0 && (_pkg$access2 = pkg.access) !== null && _pkg$access2 !== void 0 && _pkg$access2.includes('$anonymous')) {
|
|
97
|
+
debug('%o has been granted access', user === null || user === void 0 ? void 0 : user.name);
|
|
98
|
+
return cb(null, true);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!(user !== null && user !== void 0 && user.name)) {
|
|
102
|
+
const err = _core.errorUtils.getForbidden('not allowed to access package');
|
|
103
|
+
|
|
104
|
+
this._logger.debug({
|
|
105
|
+
user: user.name
|
|
106
|
+
}, 'user: @{user} not allowed to access package');
|
|
107
|
+
|
|
108
|
+
debug('%o not allowed to access package err', user === null || user === void 0 ? void 0 : user.name, err.message);
|
|
109
|
+
return cb(err);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (pkg !== null && pkg !== void 0 && (_pkg$access3 = pkg.access) !== null && _pkg$access3 !== void 0 && _pkg$access3.includes(user === null || user === void 0 ? void 0 : user.name) || pkg !== null && pkg !== void 0 && (_pkg$access4 = pkg.access) !== null && _pkg$access4 !== void 0 && _pkg$access4.includes('$authenticated')) {
|
|
113
|
+
debug('%o has been granted access', user === null || user === void 0 ? void 0 : user.name);
|
|
114
|
+
return cb(null, true);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const err = _core.errorUtils.getForbidden('not allowed to access package');
|
|
118
|
+
|
|
119
|
+
debug('%o not allowed to access package err', user === null || user === void 0 ? void 0 : user.name, err === null || err === void 0 ? void 0 : err.message);
|
|
120
|
+
return cb(err);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
allow_publish(user, pkg, cb) {
|
|
124
|
+
var _pkg$publish, _pkg$publish2, _pkg$publish3, _pkg$publish4;
|
|
125
|
+
|
|
126
|
+
if (pkg !== null && pkg !== void 0 && (_pkg$publish = pkg.publish) !== null && _pkg$publish !== void 0 && _pkg$publish.includes('$all') || pkg !== null && pkg !== void 0 && (_pkg$publish2 = pkg.publish) !== null && _pkg$publish2 !== void 0 && _pkg$publish2.includes('$anonymous')) {
|
|
127
|
+
debug('%o has been granted to publish', user === null || user === void 0 ? void 0 : user.name);
|
|
128
|
+
return cb(null, true);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!(user !== null && user !== void 0 && user.name)) {
|
|
132
|
+
const err = _core.errorUtils.getForbidden('not allowed to publish package');
|
|
133
|
+
|
|
134
|
+
debug('%o not allowed to publish package err %o', user === null || user === void 0 ? void 0 : user.name, err.message);
|
|
135
|
+
return cb(err);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (pkg !== null && pkg !== void 0 && (_pkg$publish3 = pkg.publish) !== null && _pkg$publish3 !== void 0 && _pkg$publish3.includes(user.name) || pkg !== null && pkg !== void 0 && (_pkg$publish4 = pkg.publish) !== null && _pkg$publish4 !== void 0 && _pkg$publish4.includes('$authenticated')) {
|
|
139
|
+
return cb(null, true);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const err = _core.errorUtils.getForbidden('not allowed to publish package');
|
|
143
|
+
|
|
144
|
+
debug('%o not allowed to publish package err %o', user === null || user === void 0 ? void 0 : user.name, err.message);
|
|
145
|
+
return cb(err);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
exports.default = Memory;
|
|
151
|
+
//# sourceMappingURL=Memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Memory.ts"],"names":["debug","Memory","constructor","config","appOptions","_users","users","_config","_logger","logger","_app_config","authenticate","user","password","done","userCredentials","err","errorUtils","getUnauthorized","API_ERROR","BAD_USERNAME_PASSWORD","adduser","max_users","Object","keys","length","getConflict","MAX_USERS_REACHED","name","changePassword","username","newPassword","cb","getNotFound","allow_access","pkg","access","includes","getForbidden","message","allow_publish","publish"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAYA,MAAMA,KAAK,GAAG,oBAAW,mCAAX,CAAd;;AAEe,MAAMC,MAAN,CAA2D;AAMjEC,EAAAA,WAAW,CAChBC,MADgB,EAEhBC,UAFgB,EAGhB;AACA,SAAKC,MAAL,GAAcF,MAAM,CAACG,KAAP,IAAgB,EAA9B;AACA,SAAKC,OAAL,GAAeJ,MAAf;AACA,SAAKK,OAAL,GAAeJ,UAAU,CAACK,MAA1B;AACA,SAAKC,WAAL,GAAmBN,UAAU,CAACD,MAA9B;AACAH,IAAAA,KAAK,CAAC,aAAD,CAAL;AACD;;AAEMW,EAAAA,YAAY,CAACC,IAAD,EAAeC,QAAf,EAAiCC,IAAjC,EAAuD;AACxEd,IAAAA,KAAK,CAAC,oBAAD,EAAuBY,IAAvB,EAA6BC,QAA7B,CAAL;AACA,UAAME,eAAe,GAAG,KAAKV,MAAL,CAAYO,IAAZ,CAAxB;;AAEA,QAAI,CAACG,eAAL,EAAsB;AACpBf,MAAAA,KAAK,CAAC,wBAAD,EAA2BY,IAA3B,CAAL;AACA,aAAOE,IAAI,CAAC,IAAD,EAAO,KAAP,CAAX;AACD;;AAED,QAAID,QAAQ,KAAKE,eAAe,CAACF,QAAjC,EAA2C;AACzC,YAAMG,GAAG,GAAGC,iBAAWC,eAAX,CAA2BC,gBAAUC,qBAArC,CAAZ;;AACApB,MAAAA,KAAK,CAAC,0BAAD,EAA6BY,IAA7B,CAAL;AAEA,aAAOE,IAAI,CAACE,GAA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AkCA,GAAlC,gCAAkCA,GAAG,CAAEM,OAAvC,0CAAkC,cAAcJ,QAAd,CAAuB,YAAvB,CAAtC,EAA4E;AAC1ErC,MAAAA,KAAK,CAAC,gCAAD,EAAmCY,IAAnC,aAAmCA,IAAnC,uBAAmCA,IAAI,CAAEgB,IAAzC,CAAL;AACA,aAAOI,EAAE,CAAC,IAAD,EAAO,IAAP,CAAT;AACD;;AAED,QAAI,EAACpB,IAAD,aAACA,IAAD,eAACA,IAAI,CAAEgB,IAAP,CAAJ,EAAiB;AACf,YAAMZ,GAAG,GAAGC,iBAAWqB,YAAX,CAAwB,gCAAxB,CAAZ;;AACAtC,MAAAA,KAAK,CAAC,0CAAD,EAA6CY,IAA7C,aAA6CA,IAA7C,uBAA6CA,IAAI,CAAEgB,IAAnD,EAAyDZ,GAAG,CAACuB,OAA7D,CAAL;AACA,aAAOP,EAAE,CAAChB,GAAD,CAAT;AACD;;AAED,QAAImB,GAAG,SAAH,IAAAA,GAAG,WAAH,qBAAAA,GAAG,CAAEM,OAAL,wDAAcJ,QAAd,CAAuBzB,IAAI,CAACgB,IAA5B,KAAqCO,GAArC,aAAqCA,GAArC,gCAAqCA,GAAG,CAAEM,OAA1C,0CAAqC,cAAcJ,QAAd,CAAuB,gBAAvB,CAAzC,EAAmF;AACjF,aAAOL,EAAE,CAAC,IAAD,EAAO,IAAP,CAAT;AACD;;AAED,UAAMhB,GAAG,GAAGC,iBAAWqB,YAAX,CAAwB,gCAAxB,CAAZ;;AACAtC,IAAAA,KAAK,CAAC,0CAAD,EAA6CY,IAA7C,aAA6CA,IAA7C,uBAA6CA,IAAI,CAAEgB,IAAnD,EAAyDZ,GAAG,CAACuB,OAA7D,CAAL;AAEA,WAAOP,EAAE,CAAChB,GAAD,CAAT;AACD;;AA9HuE","sourcesContent":["import buildDebug from 'debug';\n\nimport { API_ERROR, errorUtils } from '@verdaccio/core';\nimport {\n Callback,\n IPluginAuth,\n Logger,\n PackageAccess,\n PluginOptions,\n RemoteUser,\n} from '@verdaccio/types';\n\nimport { UserMemory, Users, VerdaccioMemoryConfig } from './types';\n\nconst debug = buildDebug('verdaccio:plugin:auth:memory:user');\n\nexport default class Memory implements IPluginAuth<VerdaccioMemoryConfig> {\n public _logger: Logger;\n public _users: Users;\n public _config: {};\n public _app_config: VerdaccioMemoryConfig;\n\n public constructor(\n config: VerdaccioMemoryConfig,\n appOptions: PluginOptions<VerdaccioMemoryConfig>\n ) {\n this._users = config.users || {};\n this._config = config;\n this._logger = appOptions.logger;\n this._app_config = appOptions.config;\n debug('initialized');\n }\n\n public authenticate(user: string, password: string, done: Callback): void {\n debug('authenticate %o:%o', user, password);\n const userCredentials = this._users[user];\n\n if (!userCredentials) {\n debug('user %o does not exist', user);\n return done(null, false);\n }\n\n if (password !== userCredentials.password) {\n const err = errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD);\n debug('password invalid for: %o', user);\n\n return done(err);\n }\n\n // authentication succeeded!\n // return all usergroups this user has access to;\n debug('authentication succeed for %o', user);\n return done(null, [user]);\n }\n\n public adduser(user: string, password: string, done: Callback): void {\n if (this._users[user]) {\n debug('user %o already exist', user);\n return done(null, true);\n }\n\n if (this._app_config.max_users) {\n if (Object.keys(this._users).length >= this._app_config.max_users) {\n const err = errorUtils.getConflict(API_ERROR.MAX_USERS_REACHED);\n debug(API_ERROR.MAX_USERS_REACHED);\n return done(err);\n }\n }\n\n this._users[user] = { name: user, password: password };\n\n debug('user added succeeded for %o', user);\n done(null, user);\n }\n\n public changePassword(\n username: string,\n password: string,\n newPassword: string,\n cb: Callback\n ): void {\n const user: UserMemory = this._users[username];\n debug('init change password for %o', user?.name);\n\n if (user && user.password === password) {\n user.password = newPassword;\n this._users[username] = user;\n debug('user changed password succeeded for %o', user?.name);\n cb(null, user);\n } else {\n const err = errorUtils.getNotFound('user not found');\n this._logger.debug({ user: username }, 'change password user @{user} not found');\n debug('change password user for %o not found', user?.name);\n return cb(err);\n }\n }\n\n public allow_access(user: RemoteUser, pkg: PackageAccess, cb: Callback): void {\n debug('allow access for %o', user);\n if (pkg?.access?.includes('$all') || pkg?.access?.includes('$anonymous')) {\n debug('%o has been granted access', user?.name);\n\n return cb(null, true);\n }\n\n if (!user?.name) {\n const err = errorUtils.getForbidden('not allowed to access package');\n this._logger.debug({ user: user.name }, 'user: @{user} not allowed to access package');\n debug('%o not allowed to access package err', user?.name, err.message);\n return cb(err);\n }\n\n if (pkg?.access?.includes(user?.name) || pkg?.access?.includes('$authenticated')) {\n debug('%o has been granted access', user?.name);\n return cb(null, true);\n }\n\n const err = errorUtils.getForbidden('not allowed to access package');\n debug('%o not allowed to access package err', user?.name, err?.message);\n return cb(err);\n }\n\n public allow_publish(user: RemoteUser, pkg: PackageAccess, cb: Callback): void {\n if (pkg?.publish?.includes('$all') || pkg?.publish?.includes('$anonymous')) {\n debug('%o has been granted to publish', user?.name);\n return cb(null, true);\n }\n\n if (!user?.name) {\n const err = errorUtils.getForbidden('not allowed to publish package');\n debug('%o not allowed to publish package err %o', user?.name, err.message);\n return cb(err);\n }\n\n if (pkg?.publish?.includes(user.name) || pkg?.publish?.includes('$authenticated')) {\n return cb(null, true);\n }\n\n const err = errorUtils.getForbidden('not allowed to publish package');\n debug('%o not allowed to publish package err %o', user?.name, err.message);\n\n return cb(err);\n }\n}\n"],"file":"Memory.js"}
|
package/{lib → build}/index.d.ts
RENAMED
|
File without changes
|
package/{lib → build}/index.js
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config } from '@verdaccio/types';
|
|
2
|
+
export interface UserMemory {
|
|
3
|
+
name: string;
|
|
4
|
+
password: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Users {
|
|
7
|
+
[key: string]: UserMemory;
|
|
8
|
+
}
|
|
9
|
+
export interface VerdaccioMemoryConfig extends Config {
|
|
10
|
+
max_users?: number;
|
|
11
|
+
users: Users;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"index.js"}
|