-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yaml
634 lines (621 loc) · 17.4 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
openapi: 3.0.3
info:
title: Sleutelkastje
description: Sleutelkastje
version: $VERSION_NUMBER
servers:
- url: '$BASE_DOMAIN/api'
tags:
- name: Applications
description: Manage and view applications registered with the Sleutelkastje application
- name: Invitations
description: Invitations for allowing users to gain access to an application
- name: Items
description: Items are subsets of an application. This allows for more fine-grained access control in applications. Users can have permissions set on a per-item level, not just for the entire application.
- name: User data
description: Information about the current user
- name: API Keys
description: Create and get API keys for authentication to the apps in the Sleutelkastje
- name: User validation
description: These endpoints can be used to validate users. This can either include sending an API key in order to get the user information and items/roles for the application, or just getting the permissions and roles for a known username of the application.
paths:
/apps/list:
get:
summary: List applications
description: Get a list of all the application the currently authenticated user can see.
tags:
- Applications
security:
- ApiKey: []
responses:
200:
description: A list of all the applications the user can see
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
/apps/{appId}/details:
get:
summary: Get application
description: Get the details of a specific application
tags:
- Applications
security:
- ApiKey: []
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
responses:
200:
description: The details of a specific application
content:
application/json:
schema:
$ref: '#/components/schemas/Application'
/admin/apps/{appId}:
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
get:
deprecated: true
tags:
- Applications
security:
- ApiKey: []
description: (Admin) Get app details
responses:
200:
description: Application details
put:
summary: (Admin) Create or update application
description: Create a new application or update an existing one
tags:
- Applications
security:
- ApiKey: []
requestBody:
description: Application details
content:
application/json:
schema:
type: object
properties:
credentials:
type: string
redirect:
type: string
name:
type: string
responses:
200:
description: Application updated
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: "updated"
message:
type: string
default: "Application updated"
application:
type: string
201:
description: Application created
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: "created"
message:
type: string
default: "Application created"
application:
type: string
invitation:
description: Invitation with role 'operator' for the new application
type: string
/apps/{appId}/items:
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
get:
description: Get all items of this application
tags:
- Items
security:
- ApiKey: []
responses:
200:
description: A list of items
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Item'
post:
description: Create a new item for this application
tags:
- Items
security:
- ApiKey: []
requestBody:
description: Item details
content:
application/json:
schema:
type: object
properties:
name:
type: string
example: "data-story-1"
responses:
201:
description: The created item
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: true
message:
type: string
default: "Item created"
item:
$ref: '#/components/schemas/Item'
/apps/{appId}/validate:
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
post:
summary: Validate by key
description: Validate an API key and get user information
tags:
- User validation
security:
- ApiKey: []
requestBody:
description: User information
content:
application/json:
schema:
type: object
properties:
key:
type: string
responses:
200:
description: Key valid for this application, user info retrieved
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: success
userData:
$ref: '#/components/schemas/UserMinimal'
items:
$ref: '#/components/schemas/ItemRoles'
/apps/{appId}/userinfo:
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
post:
summary: Validate by username
description: Validate that a username is known to the application, and get associated permissions.
tags:
- User validation
security:
- ApiKey: []
requestBody:
description: User information
content:
application/json:
schema:
type: object
properties:
username:
type: string
example: "[email protected]"
responses:
200:
description: Username known to this application, user info retrieved
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: success
userData:
$ref: '#/components/schemas/UserMinimal'
items:
$ref: '#/components/schemas/ItemRoles'
/apps/{appId}/invitations:
parameters:
- name: appId
description: The identifier of the application
in: path
schema:
type: string
get:
description: Get the invitations for an application
tags:
- Invitations
security:
- ApiKey: []
responses:
200:
description: A list of invitations
content:
application/json:
schema:
type: object
properties:
invites:
type: array
items:
$ref: '#/components/schemas/Invitation'
post:
description: Create a new invitation for an application
tags:
- Invitations
security:
- ApiKey: []
requestBody:
description: Invitation details
content:
application/json:
schema:
type: object
properties:
role:
type: string
pattern: '^[0-9a-f\-]+'
example: 'user'
itemRoles:
$ref: '#/components/schemas/ItemRoles'
responses:
201:
description: The newly created invitation
content:
application/json:
schema:
$ref: '#/components/schemas/Invitation'
delete:
description: Delete invitations for an application
security:
- ApiKey: []
tags:
- Invitations
requestBody:
description:
Invitations to delete
content:
application/json:
schema:
type: object
properties:
ids:
type: array
items:
type: integer
responses:
200:
description: Invitations deleted
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: true
400:
description: Invalid input
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: false
error:
type: string
example: "No IDs provided"
/invitations/{invitationId}:
get:
security:
- ApiKey: []
tags:
- Invitations
description: Get details of a specific invitation
responses:
200:
description: Invitation details
content:
application/json:
schema:
$ref: '#/components/schemas/Invitation'
post:
security:
- ApiKey: []
tags:
- Invitations
description: Accept or reject an invitation
requestBody:
description: Action to perform
content:
application/json:
schema:
type: object
properties:
action:
type: string
responses:
200:
description: Success
/api/auth/me:
get:
security:
- ApiKey: []
tags:
- User data
summary: Get user info
description: Get the details of the current user
responses:
200:
description: User info
content:
application/json:
schema:
$ref: '#/components/schemas/User'
/api/auth/complete-profile:
post:
security:
- ApiKey: []
tags:
- User data
summary: Complete profile
description: Complete the profile of the current user
requestBody:
description: User data
content:
application/json:
schema:
type: object
properties:
nickname:
description: Nickname to set for the user
type: string
example: John Doe
responses:
200:
description: Success
/api/auth/change-password:
post:
security:
- ApiKey: []
tags:
- User data
summary: Change password
description: Change your user account password
requestBody:
description: Old and new password
content:
application/json:
schema:
type: object
properties:
oldPassword:
type: string
newPassword:
type: string
responses:
200:
description: Password changed
content:
application/json:
schema:
type: object
properties:
status:
type: string
default: "success"
message:
type: string
default: "Password changed"
/api/keys:
get:
security:
- ApiKey: []
tags:
- API Keys
summary: Get API Keys
description: Get all API keys of the current user
responses:
200:
description: API Keys
content:
application/json:
schema:
type: object
properties:
keys:
type: array
items:
$ref: '#/components/schemas/APIKey'
post:
security:
- ApiKey: []
tags:
- API Keys
summary: Create API key
description: Create a new API key. Note that the response of this request is the only time you can see the raw value of the key.
requestBody:
description: API Key details
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
description: Name by which to identify this key
type: string
appMnemonic:
description: Mnemonic of the app this key is for. Leave this empty or omit the field if you need a key for interacting with the Sleutelkastje API itself
responses:
201:
description: Success and API key
content:
application/json:
schema:
type: object
properties:
name:
type: string
key:
type: string
components:
securitySchemes:
ApiKey:
type: apiKey
in: header
name: Authorization
schemas:
Application:
type: object
properties:
mnemonic:
type: string
pattern: '^[0-9a-f\-]+'
example: 'todo-list'
name:
type: string
example: "To Do List"
currentRole:
type: string
pattern: '^[0-9a-f\-]+'
example: "user"
Invitation:
type: object
properties:
id:
type: integer
user:
description: The user who has accepted the invitation, if any. `Null` otherwise.
nullable: true
$ref: '#/components/schemas/User'
role:
description: The role the user has on the application level
type: string
pattern: '^[0-9a-f\-]+'
example: 'user'
appId:
description: The unique mnemonic of the application
type: string
pattern: '^[0-9a-f\-]+'
example: 'todo-list'
appName:
description: The readable name of the application
type: string
example: "ToDo List"
itemRoles:
$ref: '#/components/schemas/ItemRoles'
code:
description: The unique key of this invitation
type: string
ItemRoles:
description: An object containing the role for every item to which you wish to give the user access. Keys must match the `name` of an existing item belonging to this application. The values are the 'role' the user has for that item. They do not have meaning within the Sleutelkastje, so what they need to be depends on the app using these items itself.
type: object
additionalProperties:
x-additionalPropertiesName: item-name
type: string
pattern: '^[0-9a-f\-]+'
example:
'data-story-1': user
'data-story-2': owner
Item:
type: object
properties:
id:
type: integer
name:
pattern: '^[0-9a-f\-]+'
example: 'data-story-1'
APIKey:
type: object
properties:
name:
type: string
example: My API key
application:
type: string
example: Sleutelkastje
readable_part:
type: string
pattern: '^huc:.{16}'
User:
type: object
properties:
username:
type: string
example: '[email protected]'
nickname:
type: string
example: John Doe
role:
type: string
example: user
pattern: '^[0-9a-f\-]+'
profileComplete:
type: boolean
isOidc:
type: boolean
UserMinimal:
type: object
properties:
username:
type: string
example: '[email protected]'
nickname:
type: string
example: John Doe
role:
type: string
example: user
pattern: '^[0-9a-f\-]+'