-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yaml
More file actions
1009 lines (1009 loc) · 25.1 KB
/
swagger.yaml
File metadata and controls
1009 lines (1009 loc) · 25.1 KB
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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
basePath: /api
definitions:
AuthUpdateMessage:
description: Message that is sent to notify subscribers (e.g. Beacon) on changes
to one of these authentication related values
properties:
api_token:
description: the actual API token
type: string
expires_at:
description: expiration date of this token
type: string
permanent:
description: no expiration (ignore ExpiresAt)
type: boolean
roles:
description: roles associated with this token
items:
type: string
type: array
username:
description: unique username associated with this token
type: string
type: object
CreateOrUpdateRolePayload:
properties:
name:
type: string
type: object
CreateOrUpdateUserPayload:
properties:
email:
type: string
password:
type: string
username:
type: string
type: object
CreateRegistrationKeyPayload:
properties:
description:
type: string
expires_at:
type: string
key:
type: string
permanent:
type: boolean
type: object
LoginPayload:
properties:
password:
type: string
username:
type: string
type: object
RegisterPayload:
properties:
email:
type: string
password:
type: string
registration_key:
description: snake case naming for decoding of x-www-form-urlencoded bodies
type: string
username:
type: string
type: object
RegistrationKey:
description: A registration key that can be permanent or expire at a specified
date and time with which new users can register an account
properties:
created_at:
description: ISO 8601 datetime
type: string
description:
description: a description for this registration key
type: string
expires_at:
description: expiration date in ISO 8601 datetime
type: string
id:
description: id (primary key)
type: integer
key:
description: unique registration key
type: string
permanent:
description: if set, ignores the expires_at field and never expires this key
type: boolean
updated_at:
description: ISO 8601 datetime
type: string
type: object
Role:
description: A named role that describes a group of users sharing the same permissions
properties:
created_at:
description: ISO 8601 datetime
type: string
id:
description: id (primary key)
type: integer
name:
description: unique name of the role
type: string
updated_at:
description: ISO 8601 datetime
type: string
type: object
Token:
description: API token that allows access to the websocket API (beacon) and probably
other APIs in the future
properties:
api_token:
type: string
created_at:
description: ISO 8601 datetime
type: string
expires_at:
description: ISO 8601 datetime
type: string
permanent:
description: if permanent is true, expires_at is ignored
type: boolean
updated_at:
description: ISO 8601 datetime
type: string
type: object
UpdateRegistrationKeyPayload:
properties:
description:
type: string
expires_at:
type: string
permanent:
type: boolean
type: object
User:
description: User account information including username, email, last login date
and time, permanent API token flag, registration key (if user registered with
a key) and roles
properties:
api_token:
allOf:
- $ref: '#/definitions/Token'
description: omitted if null (user doesn't have an API token)
created_at:
description: ISO 8601 datetime
type: string
email:
description: can be empty
type: string
id:
description: id (primary key)
type: integer
last_login:
description: ISO 8601 datetime
type: string
registration_key:
allOf:
- $ref: '#/definitions/RegistrationKey'
description: omitted if null (when user was created and not registered or
when list of users is queried to not leak other users keys)
roles:
items:
$ref: '#/definitions/Role'
type: array
updated_at:
description: ISO 8601 datetime
type: string
username:
description: must be unique
type: string
type: object
UserUpdateMessage:
description: Message that is sent to notify subscribers (e.g. Beacon) when a new
user is created or a user is removed
properties:
removed:
type: boolean
username:
type: string
type: object
handler.UpdateTokenPayload:
properties:
permanent:
type: boolean
type: object
host: https://lighthouse.uni-kiel.de
info:
contact: {}
description: |-
This is the REST API of Project Lighthouse that manages users, roles, registration keys, API tokens and everything about authentication and authorization.
NOTE: This API is an early alpha version that still needs a lot of testing (unit tests, end-to-end tests and security tests)
title: Heimdall Lighthouse API
version: "0.1"
paths:
/internal/authenticate/{username}:
post:
description: If the initial request was successful, the connection is kept alive
and updates are sent using server sent events (SSE).
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/AuthUpdateMessage'
"400":
description: Bad Request
"401":
description: Unauthorized
"500":
description: Internal Server Error
summary: Get and subscribe to updates of a user's api token and roles
tags:
- Internal
/internal/users:
get:
description: Returns a list of all users names
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/UserUpdateMessage'
type: array
"401":
description: Unauthorized
"500":
description: Internal Server Error
summary: Get a list of all usernames
tags:
- Internal
/login:
post:
consumes:
- application/json
description: Log in with username and password (sets a cookie with the session
id). Returns the full user information if the login was successful or the
user is already logged in.
parameters:
- description: Username and Password
in: body
name: payload
required: true
schema:
$ref: '#/definitions/LoginPayload'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/User'
"400":
description: Bad Request
"401":
description: Unauthorized
"500":
description: Internal Server Error
summary: Login
tags:
- Users
/logout:
post:
consumes:
- application/json
description: Log out of the current session
produces:
- text/plain
responses:
"200":
description: OK
"401":
description: Unauthorized
"500":
description: Internal Server Error
summary: Logout
tags:
- Users
/register:
post:
consumes:
- application/json
description: Registers a new user using a registration key
parameters:
- description: Username, Password, Email, RegistrationKey
in: body
name: payload
required: true
schema:
$ref: '#/definitions/RegisterPayload'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/User'
"400":
description: Bad Request
"401":
description: Unauthorized
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Register user
tags:
- Users
/registration-keys:
get:
consumes:
- application/json
description: Get a list of all registration keys or query a single registration
key by key (returns single object instead of list)
parameters:
- description: Registration Key
in: query
name: key
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/RegistrationKey'
type: array
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get all registration keys or query by key
tags:
- RegistrationKeys
post:
consumes:
- application/json
description: Create a new registration key
parameters:
- description: key, description, permament, expires_at
in: body
name: payload
required: true
schema:
$ref: '#/definitions/CreateRegistrationKeyPayload'
produces:
- text/plain
responses:
"201":
description: Created
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Create registration key
tags:
- RegistrationKeys
/registration-keys/{id}:
delete:
description: Delete a registration key by its id
parameters:
- description: Registration Key ID
in: path
name: id
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Delete registration key
tags:
- RegistrationKeys
get:
consumes:
- application/json
description: Get a registration key by its id
parameters:
- description: Registration Key ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/RegistrationKey'
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get registration key by id
tags:
- RegistrationKeys
put:
consumes:
- application/json
description: Upadte a registration key by its id
parameters:
- description: Registration Key ID
in: path
name: id
required: true
type: integer
- description: description, permament, expires_at
in: body
name: payload
required: true
schema:
$ref: '#/definitions/UpdateRegistrationKeyPayload'
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"500":
description: Internal Server Error
summary: Update registration key
tags:
- RegistrationKeys
/registration-keys/{id}/users:
get:
description: 'Get a list of users that registered using this registration key
by its id. NOTE: registration_key is not included for users'
parameters:
- description: Registration Key ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/User'
type: array
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get users of registration key
tags:
- RegistrationKeys
/roles:
get:
description: Get a list of all roles or query a single role by name (returns
single object instead of list)
parameters:
- description: Role name
in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/Role'
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get all roles or query by name
tags:
- Roles
post:
consumes:
- application/json
description: Create a new role
parameters:
- description: Name
in: body
name: payload
required: true
schema:
$ref: '#/definitions/CreateOrUpdateRolePayload'
produces:
- text/plain
responses:
"201":
description: Created
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Create role
tags:
- Roles
/roles/{id}:
delete:
description: Delete a role by its role id
parameters:
- description: Role ID
in: path
name: id
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Delete role
tags:
- Roles
get:
description: Get a role by its role id
parameters:
- description: Role ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/Role'
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get role by id
tags:
- Roles
put:
consumes:
- application/json
description: Update a new role by its user id
parameters:
- description: Role ID
in: path
name: id
required: true
type: integer
- description: Name
in: body
name: payload
required: true
schema:
$ref: '#/definitions/CreateOrUpdateRolePayload'
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Update role
tags:
- Roles
/roles/{id}/users:
get:
description: 'Get a list of users that have a role by its role id. NOTE: registration_key
is not included for users'
parameters:
- description: Role ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/User'
type: array
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get users of role
tags:
- Roles
/roles/{roleid}/users/{userid}:
delete:
description: Remove a user (by its user id) from a role (by its role id)
parameters:
- description: Role ID
in: path
name: roleid
required: true
type: integer
- description: User ID
in: path
name: userid
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Remove user from role
tags:
- Roles
put:
description: Add a user (by its user id) to a role (by its role id)
parameters:
- description: Role ID
in: path
name: roleid
required: true
type: integer
- description: User ID
in: path
name: userid
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Add user to role
tags:
- Roles
/users:
get:
description: 'Get a list of all users or query a single user by name (returns
single object instead of list). NOTE: registration_key is only included when
querying a single user'
parameters:
- description: Username
in: query
name: name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/User'
type: array
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get all users or query by name
tags:
- Users
post:
consumes:
- application/json
description: Creates a new user
parameters:
- description: Username, Password, Email
in: body
name: payload
required: true
schema:
$ref: '#/definitions/CreateOrUpdateUserPayload'
produces:
- text/plain
responses:
"201":
description: Created
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Create user
tags:
- Users
/users/{id}:
delete:
description: Deletes a user given a user id
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Delete user
tags:
- Users
get:
description: Get a user by its user id
operationId: GetUserByName
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/User'
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get user by id
tags:
- Users
put:
consumes:
- application/json
description: Updates a user (always updates all fields, partial updates currently
not supported)
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
- description: Username, Password, Email
in: body
name: payload
required: true
schema:
$ref: '#/definitions/CreateOrUpdateUserPayload'
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"409":
description: Conflict
"500":
description: Internal Server Error
summary: Update user
tags:
- Users
/users/{id}/api-token:
delete:
description: Given a valid user id, invalidates the current API token and generates
a new one
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- text/plain
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Renew a user's API token
tags:
- Users
get:
description: Given a valid user id, returns the username, API token, associated
roles and expiration date
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/Token'
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Get a user's API token
tags:
- Users
put:
description: Given a valid user id and new permanent status, sets the permanent
status for the users current token
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
- description: Set whether this token is permanent (does not expire)
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handler.UpdateTokenPayload'
produces:
- application/json
responses:
"200":
description: OK
"400":
description: Bad Request
"401":
description: Unauthorized
"403":
description: Forbidden
"404":
description: Not Found
"500":
description: Internal Server Error
summary: Update a user's API token (set permanent)
tags:
- Users
/users/{id}/roles:
get:
description: Get a list of roles that a user posesses
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/Role'
type: array
"400":
description: Bad Request
"401":
description: Unauthorized
"403":