-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathapi.yaml
More file actions
829 lines (807 loc) · 24.6 KB
/
api.yaml
File metadata and controls
829 lines (807 loc) · 24.6 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
openapi: 3.0.3
info:
version: v1alpha1
title: User Management API
description: API for managing users, their passwords, and permissions.
contact:
name: Antfly
url: https://github.com/antflydb/antfly
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: /api/v1
description: Main API server
security:
- BasicAuth: []
- ApiKeyAuth: []
- BearerAuth: []
tags:
- name: User
x-displayName: User
description: Operations related to users
- name: Permission
x-displayName: Permission
description: Operations related to permissions
- name: ApiKey
x-displayName: API Key
description: Operations related to API key management
- name: RowFilter
x-displayName: Row Filter
description: Operations related to row-level security filters
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
ApiKeyAuth:
type: apiKey
in: header
name: Authorization
BearerAuth:
type: http
scheme: bearer
schemas:
User:
type: object
properties:
username:
type: string
example: johndoe
password_hash:
type: string
format: byte # Typically base64 encoded
description: "Base64 encoded password hash. Exposing this is a security risk."
example: "JGFyZ29uMm..."
required:
- username
- password_hash
ResourceType:
type: string
enum: ["table", "user", "*"]
description: "Type of the resource, e.g., table, user, or global ('*')."
example: "table"
PermissionType:
type: string
enum: ["read", "write", "admin"]
description: "Type of permission."
example: "read"
Permission:
type: object
properties:
resource:
type: string
description: "Resource name (e.g., table name, target username, or '*' for global)."
example: "orders_table"
resource_type:
$ref: "#/components/schemas/ResourceType"
type:
$ref: "#/components/schemas/PermissionType"
required:
- resource
- resource_type
- type
CreateUserRequest:
type: object
properties:
username:
type: string
description: "Username for the new user. If provided in the path, this field can be omitted or must match the path parameter."
example: "johndoe"
password:
type: string
format: password
example: "s3cr3tP@sswOrd"
initial_policies:
type: array
items:
$ref: "#/components/schemas/Permission"
nullable: true
description: "Optional list of initial permissions for the user."
required:
- password # Username can be taken from path, password must be in body.
UpdatePasswordRequest:
type: object
properties:
new_password:
type: string
format: password
example: "newS3cr3tP@sswOrd"
required:
- new_password
SuccessMessage:
type: object
properties:
message:
type: string
example: "Operation completed successfully"
Error:
type: object
properties:
error:
type: string
example: "An error message"
required:
- error
ApiKey:
type: object
description: "Public metadata for an API key (secrets are never returned after creation)."
properties:
key_id:
type: string
description: "Unique identifier for the API key."
example: "aBcDeFgHiJkLmNoPqRsT"
name:
type: string
description: "Human-readable name for the API key."
example: "CI pipeline key"
username:
type: string
description: "Owner of the API key."
example: "johndoe"
permissions:
type: array
items:
$ref: "#/components/schemas/Permission"
nullable: true
description: "Optional permission scoping. If empty, inherits owner's full permissions."
row_filter:
type: object
additionalProperties: {}
nullable: true
description: >
Per-table row filter. Keys are table names (or '*' for all tables).
Values are bleve query JSON objects. Documents must match this query
to be visible through this API key.
created_at:
type: string
format: date-time
description: "When the API key was created."
expires_at:
type: string
format: date-time
nullable: true
description: "When the API key expires. Null means never."
required:
- key_id
- name
- username
- created_at
ApiKeyWithSecret:
description: "API key creation response including the cleartext secret (shown once)."
allOf:
- $ref: "#/components/schemas/ApiKey"
- type: object
properties:
key_secret:
type: string
description: "Cleartext secret for the API key. Store securely — it cannot be retrieved again."
example: "dGhpcyBpcyBhIHNlY3JldA"
encoded:
type: string
description: "Pre-encoded credential ready for the Authorization header: base64(key_id:key_secret)."
example: "YUJjRGVGZ0hpSmtMbU5vUHFSc1Q6ZEdocGN5QnBjeUJoSUhObFkzSmxkQQ=="
required:
- key_secret
- encoded
RowFilterEntry:
type: object
description: "A row filter policy for a user on a specific table."
properties:
table:
type: string
description: "Table name (or '*' for all tables)."
example: "orders"
filter:
type: object
additionalProperties: {}
description: "Bleve query JSON that documents must match to be visible."
example:
term:
department: "engineering"
required:
- table
- filter
CreateApiKeyRequest:
type: object
description: "Request to create a new API key."
properties:
name:
type: string
description: "Human-readable name for the API key."
example: "CI pipeline key"
expires_in:
type: string
description: "Duration until expiration (e.g., '720h' for 30 days). Empty means never."
example: "720h"
permissions:
type: array
items:
$ref: "#/components/schemas/Permission"
nullable: true
description: "Optional permission scoping. Each permission must be a subset of the creator's permissions."
row_filter:
type: object
additionalProperties: {}
nullable: true
description: >
Per-table row filter. Keys are table names (or '*' for all tables).
Values are bleve query JSON objects. Documents must match this query
to be visible through this API key.
required:
- name
parameters:
UserNamePathParameter:
name: userName
in: path
required: true
description: The username.
schema:
type: string
example: "johndoe"
KeyIdPathParameter:
name: keyId
in: path
required: true
description: The API key ID.
schema:
type: string
example: "aBcDeFgHiJkLmNoPqRsT"
paths:
/users/me:
get:
tags:
- User
summary: Get current authenticated user
description: Retrieves details for the currently authenticated user.
operationId: getCurrentUser
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: object
properties:
username:
type: string
example: johndoe
permissions:
type: array
items:
$ref: "#/components/schemas/Permission"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users:
get:
tags:
- User
summary: List all users
description: Retrieves a list of all users in the system. Requires admin permission.
operationId: listUsers
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
example: johndoe
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"403":
description: Forbidden - requires admin permission
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
post:
tags:
- User
summary: Create a new user
description: Creates a new user with the given username and password. Username in path takes precedence.
operationId: createUser
requestBody:
description: User creation details
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateUserRequest"
responses:
"201":
description: User created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/User" # Reflects current Go code behavior
"400":
description: Bad Request (e.g., invalid input, username/password mismatch)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"409":
description: Conflict (e.g., user already exists)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
get:
tags:
- User
summary: Get user details
description: Retrieves details for a specific user.
operationId: getUserByName
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/User" # Reflects current Go code behavior
"400":
description: Bad Request (e.g., username is required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
delete:
tags:
- User
summary: Delete a user
description: Deletes a specific user.
operationId: deleteUser
responses:
"204":
description: User deleted successfully
"400":
description: Bad Request (e.g., username is required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/password:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
put:
tags:
- User
summary: Update user password
description: Updates the password for a specific user.
operationId: updateUserPassword
requestBody:
description: New password details
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UpdatePasswordRequest"
responses:
"200":
description: Password updated successfully
content:
application/json:
schema:
$ref: "#/components/schemas/SuccessMessage"
"400":
description: Bad Request (e.g., new password empty, username required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/permissions:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
get:
tags:
- Permission
summary: Get user permissions
description: Retrieves all permissions for a specific user.
operationId: getUserPermissions
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Permission"
"400":
description: Bad Request (e.g., username is required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
tags:
- Permission
summary: Add permission to user
description: Adds a new permission to a specific user.
operationId: addPermissionToUser
requestBody:
description: Permission details to add
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Permission"
responses:
"201":
description: Permission added successfully
content:
application/json:
schema:
$ref: "#/components/schemas/SuccessMessage"
"400":
description: Bad Request (e.g., invalid input, username required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
delete:
tags:
- Permission
summary: Remove permission from user
description: Removes a specific permission rule from a user based on resource name and type.
operationId: removePermissionFromUser
parameters:
- name: resource
in: query
required: true
description: The name of the resource for the permission to be removed.
schema:
type: string
example: "orders_table"
- name: resourceType
in: query
required: true
description: The type of the resource for the permission to be removed.
schema:
$ref: "#/components/schemas/ResourceType"
responses:
"204":
description: Permission removed successfully
"400":
description: Bad Request (e.g., missing query parameters, invalid resourceType, username required)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found or Role not found for the given resource
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/row-filters:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
get:
tags:
- RowFilter
summary: List row filters for a user
description: Returns all row filter policies for the specified user.
operationId: listRowFilters
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/RowFilterEntry"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/row-filters/{table}:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
- name: table
in: path
required: true
description: "Table name (or '*' for all tables)."
schema:
type: string
example: "orders"
get:
tags:
- RowFilter
summary: Get row filter for a user on a table
description: Returns the row filter policy for the specified user and table.
operationId: getRowFilter
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/RowFilterEntry"
"404":
description: User or row filter not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
put:
tags:
- RowFilter
summary: Set row filter for a user on a table
description: Sets or replaces the row filter policy for the specified user and table. The request body is the bleve query JSON.
operationId: setRowFilter
requestBody:
description: Bleve query JSON for filtering documents
required: true
content:
application/json:
schema:
type: object
additionalProperties: {}
responses:
"200":
description: Row filter set successfully
content:
application/json:
schema:
$ref: "#/components/schemas/RowFilterEntry"
"400":
description: Bad Request (e.g., invalid filter JSON)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
delete:
tags:
- RowFilter
summary: Remove row filter for a user on a table
description: Removes the row filter policy for the specified user and table.
operationId: removeRowFilter
responses:
"204":
description: Row filter removed successfully
"404":
description: User or row filter not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/api-keys:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
get:
tags:
- ApiKey
summary: List API keys for a user
description: Returns all API keys owned by the specified user. Secrets are never included.
operationId: listApiKeys
responses:
"200":
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ApiKey"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
tags:
- ApiKey
summary: Create a new API key
description: Creates a new API key for the specified user. The cleartext secret is returned only in this response.
operationId: createApiKey
requestBody:
description: API key creation details
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateApiKeyRequest"
responses:
"201":
description: API key created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/ApiKeyWithSecret"
"400":
description: Bad Request (e.g., invalid input)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"403":
description: Forbidden (e.g., requested permissions exceed creator's permissions)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/users/{userName}/api-keys/{keyId}:
parameters:
- $ref: "#/components/parameters/UserNamePathParameter"
- $ref: "#/components/parameters/KeyIdPathParameter"
delete:
tags:
- ApiKey
summary: Delete an API key
description: Permanently deletes the specified API key. Subsequent requests using this key will be rejected.
operationId: deleteApiKey
responses:
"204":
description: API key deleted successfully
"404":
description: API key not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"