Skip to content

Commit 2240ea4

Browse files
committed
remove registry flags, one-of, change user_id to username
1 parent 74d4355 commit 2240ea4

File tree

9 files changed

+702
-1155
lines changed

9 files changed

+702
-1155
lines changed

api-docs/openapi.json

Lines changed: 454 additions & 1124 deletions
Large diffs are not rendered by default.

schemas/registry-user/create-registry-user-request.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"title": "CVE Create Registry User Request",
66
"description": "JSON Schema for creating a CVE Registry User",
77
"properties": {
8-
"user_id": {
8+
"username": {
99
"type": "string",
1010
"description": "User's identifier or username"
1111
},
@@ -75,7 +75,7 @@
7575
}
7676
},
7777
"required": [
78-
"user_id",
78+
"username",
7979
"name"
8080
]
8181
}

schemas/registry-user/create-registry-user-response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"type": "string",
1717
"description": "Unique identifier for the user"
1818
},
19-
"user_id": {
19+
"username": {
2020
"type": "string",
2121
"description": "User's identifier or username"
2222
},

schemas/registry-user/get-registry-user-response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "string",
1010
"description": "Unique identifier for the user"
1111
},
12-
"user_id": {
12+
"username": {
1313
"type": "string",
1414
"description": "User's identifier or username"
1515
},

schemas/registry-user/update-registry-user-request.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"title": "CVE Update Registry User Request",
66
"description": "JSON Schema for updating a CVE Registry User",
77
"properties": {
8-
"user_id": {
8+
"username": {
99
"type": "string",
1010
"description": "User's identifier or username"
1111
},

schemas/registry-user/update-registry-user-response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"type": "string",
1717
"description": "Unique identifier for the user"
1818
},
19-
"user_id": {
19+
"username": {
2020
"type": "string",
2121
"description": "User's identifier or username"
2222
},

src/controller/org.controller/index.js

Lines changed: 230 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,80 @@ router.get('/registry/org/:identifier',
4848
controller.ORG_SINGLE
4949
)
5050
router.get('/registry/org/:shortname/user/:username',
51+
/*
52+
#swagger.tags = ['Registry User']
53+
#swagger.operationId = 'registryUserSingle'
54+
#swagger.summary = "Retrieves information about a user for the specified username and organization short name (accessible to all registered users)"
55+
#swagger.description = "
56+
<h2>Access Control</h2>
57+
<p>All registered users can access this endpoint</p>
58+
<h2>Expected Behavior</h2>
59+
<p><b>Regular, CNA & Admin Users:</b> Retrieves information about a registry user in the same organization</p>
60+
<p><b>Secretariat:</b> Retrieves any registry user's information</p>"
61+
#swagger.parameters['shortname'] = {
62+
description: 'The shortname of the organization'
63+
}
64+
#swagger.parameters['username'] = {
65+
description: 'The username of the registry user',
66+
schema: {
67+
type: 'string',
68+
pattern: '^[a-zA-Z0-9._@-]+$' // Based on isValidUsername custom validator
69+
}
70+
}
71+
#swagger.parameters['$ref'] = [
72+
'#/components/parameters/apiEntityHeader',
73+
'#/components/parameters/apiUserHeader',
74+
'#/components/parameters/apiSecretHeader'
75+
]
76+
#swagger.responses[200] = {
77+
description: 'Returns information about the specified registry user',
78+
content: {
79+
"application/json": {
80+
schema: { $ref: '../schemas/registry-user/get-registry-user-response.json' }
81+
}
82+
}
83+
}
84+
#swagger.responses[400] = {
85+
description: 'Bad Request',
86+
content: {
87+
"application/json": {
88+
schema: { $ref: '../schemas/errors/bad-request.json' }
89+
}
90+
}
91+
}
92+
#swagger.responses[401] = {
93+
description: 'Not Authenticated',
94+
content: {
95+
"application/json": {
96+
schema: { $ref: '../schemas/errors/generic.json' }
97+
}
98+
}
99+
}
100+
#swagger.responses[403] = {
101+
description: 'Forbidden',
102+
content: {
103+
"application/json": {
104+
schema: { $ref: '../schemas/errors/generic.json' }
105+
}
106+
}
107+
}
108+
#swagger.responses[404] = {
109+
description: 'Not Found',
110+
content: {
111+
"application/json": {
112+
schema: { $ref: '../schemas/errors/generic.json' }
113+
}
114+
}
115+
}
116+
#swagger.responses[500] = {
117+
description: 'Internal Server Error',
118+
content: {
119+
"application/json": {
120+
schema: { $ref: '../schemas/errors/generic.json' }
121+
}
122+
}
123+
}
124+
*/
51125
mw.useRegistry(),
52126
mw.validateUser,
53127
param(['shortname']).isString().trim().notEmpty().isLength({ min: CONSTANTS.MIN_SHORTNAME_LENGTH, max: CONSTANTS.MAX_SHORTNAME_LENGTH }),
@@ -75,6 +149,81 @@ router.put('/registry/org/:shortname',
75149
)
76150

77151
router.post('/registry/org/:shortname/user',
152+
/*
153+
#swagger.tags = ['Registry User']
154+
#swagger.operationId = 'registryUserCreateSingle'
155+
#swagger.summary = "Create a user with the provided short name as the owning organization (accessible to Admins and Secretariats)"
156+
#swagger.description = "
157+
<h2>Access Control</h2>
158+
<p>User must belong to an organization with the <b>Secretariat</b> role or be an <b>Admin</b> of the organization</p>
159+
<h2>Expected Behavior</h2>
160+
<p><b>Admin User:</b> Creates a user for the Admin's organization</p>
161+
<p><b>Secretariat:</b> Creates a user for any organization</p>"
162+
#swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
163+
#swagger.parameters['$ref'] = [
164+
'#/components/parameters/apiEntityHeader',
165+
'#/components/parameters/apiUserHeader',
166+
'#/components/parameters/apiSecretHeader'
167+
]
168+
#swagger.requestBody = {
169+
required: true,
170+
content: {
171+
'application/json': {
172+
schema:
173+
{ $ref: '../schemas/registry-user/create-registry-user-request.json' }
174+
}
175+
}
176+
}
177+
#swagger.responses[200] = {
178+
description: 'Returns the new user information (with the secret)',
179+
content: {
180+
"application/json": {
181+
schema:
182+
{ $ref: '../schemas/registry-user/create-registry-user-response.json' }
183+
}
184+
}
185+
}
186+
#swagger.responses[400] = {
187+
description: 'Bad Request',
188+
content: {
189+
"application/json": {
190+
schema: { $ref: '../schemas/errors/bad-request.json' }
191+
}
192+
}
193+
}
194+
#swagger.responses[401] = {
195+
description: 'Not Authenticated',
196+
content: {
197+
"application/json": {
198+
schema: { $ref: '../schemas/errors/generic.json' }
199+
}
200+
}
201+
}
202+
#swagger.responses[403] = {
203+
description: 'Forbidden',
204+
content: {
205+
"application/json": {
206+
schema: { $ref: '../schemas/errors/generic.json' }
207+
}
208+
}
209+
}
210+
#swagger.responses[404] = {
211+
description: 'Not Found',
212+
content: {
213+
"application/json": {
214+
schema: { $ref: '../schemas/errors/generic.json' }
215+
}
216+
}
217+
}
218+
#swagger.responses[500] = {
219+
description: 'Internal Server Error',
220+
content: {
221+
"application/json": {
222+
schema: { $ref: '../schemas/errors/generic.json' }
223+
}
224+
}
225+
}
226+
*/
78227
mw.useRegistry(),
79228
mw.validateUser,
80229
mw.onlySecretariatOrAdmin,
@@ -96,6 +245,82 @@ router.post('/registry/org/:shortname/user',
96245
controller.USER_CREATE_SINGLE
97246
)
98247
router.put('/registry/org/:shortname/user/:username',
248+
/*
249+
#swagger.tags = ['Registry User']
250+
#swagger.operationId = 'registryUserUpdateSingle'
251+
#swagger.summary = "Updates information about a user for the specified username and organization shortname (accessible to all registered users)"
252+
#swagger.description = "
253+
<h2>Access Control</h2>
254+
<p>All registered users can access this endpoint</p>
255+
<h2>Expected Behavior</h2>
256+
<p><b>Regular User:</b> Updates the user's own information. Only name fields may be changed.</p>
257+
<p><b>Admin User:</b> Updates information about a user in the Admin's organization. Allowed to change all fields except org_short_name. </p>
258+
<p><b>Secretariat:</b> Updates information about a user in any organization. Allowed to change all fields.</p>"
259+
#swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
260+
#swagger.parameters['username'] = { description: 'The username of the user' }
261+
#swagger.parameters['$ref'] = [
262+
'#/components/parameters/active',
263+
'#/components/parameters/activeUserRolesAdd',
264+
'#/components/parameters/activeUserRolesRemove',
265+
'#/components/parameters/nameFirst',
266+
'#/components/parameters/nameLast',
267+
'#/components/parameters/nameMiddle',
268+
'#/components/parameters/nameSuffix',
269+
'#/components/parameters/newUsername',
270+
'#/components/parameters/orgShortname',
271+
'#/components/parameters/apiEntityHeader',
272+
'#/components/parameters/apiUserHeader',
273+
'#/components/parameters/apiSecretHeader'
274+
]
275+
#swagger.responses[200] = {
276+
description: 'Returns the updated user information',
277+
content: {
278+
"application/json": {
279+
schema: { $ref: '../schemas/registry-user/update-registry-user-response.json' }
280+
}
281+
}
282+
}
283+
#swagger.responses[400] = {
284+
description: 'Bad Request',
285+
content: {
286+
"application/json": {
287+
schema: { $ref: '../schemas/errors/bad-request.json' }
288+
}
289+
}
290+
}
291+
#swagger.responses[401] = {
292+
description: 'Not Authenticated',
293+
content: {
294+
"application/json": {
295+
schema: { $ref: '../schemas/errors/generic.json' }
296+
}
297+
}
298+
}
299+
#swagger.responses[403] = {
300+
description: 'Forbidden',
301+
content: {
302+
"application/json": {
303+
schema: { $ref: '../schemas/errors/generic.json' }
304+
}
305+
}
306+
}
307+
#swagger.responses[404] = {
308+
description: 'Not Found',
309+
content: {
310+
"application/json": {
311+
schema: { $ref: '../schemas/errors/generic.json' }
312+
}
313+
}
314+
}
315+
#swagger.responses[500] = {
316+
description: 'Internal Server Error',
317+
content: {
318+
"application/json": {
319+
schema: { $ref: '../schemas/errors/generic.json' }
320+
}
321+
}
322+
}
323+
*/
99324
mw.useRegistry(),
100325
mw.validateUser,
101326
mw.onlyOrgWithPartnerRole,
@@ -663,25 +888,16 @@ router.post('/org/:shortname/user',
663888
required: true,
664889
content: {
665890
'application/json': {
666-
schema: {
667-
oneOf: [
668-
{ $ref: '../schemas/user/create-user-request.json' },
669-
{ $ref: '../schemas/registry-user/create-registry-user-request.json' }
670-
]
671-
},
891+
schema:
892+
{ $ref: '../schemas/user/create-user-request.json' }
672893
}
673894
}
674895
}
675896
#swagger.responses[200] = {
676897
description: 'Returns the new user information (with the secret)',
677898
content: {
678899
"application/json": {
679-
schema: {
680-
oneOf: [
681-
{ $ref: '../schemas/user/create-user-response.json' },
682-
{ $ref: '../schemas/registry-user/create-registry-user-response.json' }
683-
]
684-
}
900+
schema: { $ref: '../schemas/user/create-user-response.json' }
685901
}
686902
}
687903
}
@@ -758,7 +974,6 @@ router.get('/org/:shortname/user/:username',
758974
#swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
759975
#swagger.parameters['username'] = { description: 'The username of the user' }
760976
#swagger.parameters['$ref'] = [
761-
'#/components/parameters/registry',
762977
'#/components/parameters/apiEntityHeader',
763978
'#/components/parameters/apiUserHeader',
764979
'#/components/parameters/apiSecretHeader'
@@ -767,12 +982,7 @@ router.get('/org/:shortname/user/:username',
767982
description: 'Returns information about the specified user',
768983
content: {
769984
"application/json": {
770-
schema: {
771-
oneOf: [
772-
{ $ref: '../schemas/user/get-user-response.json' },
773-
{ $ref: '../schemas/registry-user/get-registry-user-response.json' }
774-
]
775-
}
985+
schema: { $ref: '../schemas/user/get-user-response.json' }
776986
}
777987
}
778988
}
@@ -856,12 +1066,7 @@ router.put('/org/:shortname/user/:username',
8561066
description: 'Returns the updated user information',
8571067
content: {
8581068
"application/json": {
859-
schema: {
860-
oneOf: [
861-
{ $ref: '../schemas/user/update-user-response.json' },
862-
{ $ref: '../schemas/registry-user/update-registry-user-response.json' }
863-
]
864-
}
1069+
schema: {$ref: '../schemas/user/update-user-response.json'}
8651070
}
8661071
}
8671072
}

0 commit comments

Comments
 (0)