-
Notifications
You must be signed in to change notification settings - Fork 49
/
sharry-openapi.yml
2239 lines (2167 loc) · 58.8 KB
/
sharry-openapi.yml
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
openapi: 3.0.0
info:
title: Sharry
version: 1.15.0-SNAPSHOT
license:
name: GPLv3
url: https://spdx.org/licenses/GPL-3.0-or-later.html
description: |
Sharry provides a way to share files with others in a convenient
way. The core functionality is provided by a server that can be
controlled via REST calls.
The calls are divided into 4 categories:
- `/open/*`: no authentication is required to access
- `/sec/*`: an authenticated user is required
- `/alias/*`: these routes are allowed with a valid *alias id*
given as header `Sharry-Alias`
- `/admin/*`: an authenticated user that is admin is required
Authentication works by logging in with username/password (or an
oauth2 flow) that generates a token that has to be sent with every
request to a secured and admin route. It is possible to sent it
via a `Cookie` header or the special `Sharry-Auth` header.
Files can be uploaded using different methods. There is an
endpoint that can take all files and meta data from one single
request. For more reliable uploads, the server implements the [tus
protocol](https://tus.io/protocols/resumable-upload.html) that
allows to resume failed or paused uploads.
tags:
- name: Information
description: Get information about this API.
- name: Authentication
description: Various methods to authenticate.
- name: Registration
description: Register a new account.
- name: Account Management
description: Admins can create/update/delete accounts.
- name: Alias
description: Edit your alias pages.
- name: Shares
description: Edit shares.
- name: Shares Upload
description: Create or Add Files
servers:
- url: /api/v2
description: Current host
security: []
paths:
/open/info/version:
get:
operationId: "open-info-version"
tags: [ Information ]
summary: Version information.
description: |
Returns version information about server application.
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/VersionInfo"
/open/info/appconfig:
get:
operationId: "open-info-appconfig"
tags: [ Information ]
summary: Basic configuration.
description: |
Return basic information for setting up a web client.
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AppConfig"
/open/auth/login:
post:
operationId: "open-auth-login-post"
tags: [ Authentication ]
summary: Authenticate with account name and password.
description: |
Authenticate with account name and password.
If successful, an authentication token is returned that can be
used for subsequent calls to protected routes.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/UserPass"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AuthResult"
/open/auth/oauth/{id}:
get:
operationId: "open-auth-oauth-id"
tags: [ Authentication ]
summary: Authenticate via OAuth2
description: |
The `id` must be a configured OAuth provider. This requests
will redirect the client to the configured provider. After
authentication there, the provider will redirect back to
sharry.
This only works, if sharry uses TLS (https), and the correct
callback-url is configured at the provider.
parameters:
- $ref: "#/components/parameters/id"
responses:
422:
description: BadRequest
303:
description: See other
/open/auth/oauth/{id}/resume:
post:
operationId: "open-auth-oauth-id-resume"
tags: [ Authentication ]
summary: Callback url from OAuth2 providers.
description: |
This endpoint is for OAuth2 providers when delegating control
back to sharry. At this stage, sharry will do basic validation
and then finishes logging into the application.
parameters:
- $ref: "#/components/parameters/id"
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
code:
type: string
responses:
'200':
description: OK
'403':
description: Forbidden
/open/auth/proxy:
post:
operationId: "open-auth-proxy"
tags: [ Authentication ]
summary: Authenticate via request headers
description: |
When using an authenticating proxy in front, this login route
can be used to rely on trusted request headers to perform
login.
responses:
'200':
description: Ok
'403':
description: Forbidden
/sec/auth/session:
post:
operationId: "sec-auth-session"
tags: [ Authentication ]
summary: Authentication with a token
description: |
Authenticate with a token. This can be used to get a new
authentication token based on another valid one.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AuthResult"
/sec/auth/logout:
post:
operationId: "sec-auth-logout"
tags: [ Authentication ]
summary: Logout.
description: |
This route informs the server about a logout. This is not
strictly necessary.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
/open/signup/register:
post:
operationId: "open-signup-register"
tags: [ Registration ]
summary: Register a new account.
description: |
Create a new account.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Registration"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/admin/signup/newinvite:
post:
operationId: "admin-signup-newinivite"
tags: [ Registration ]
summary: Generate a new invite.
description: |
When signup mode is set to "invite", sharry requires an
invitation key when signing up. These keys can be created
here. Creating such keys requires an admin user. It also asks
for a password that must be set in the configuration file.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/GenInvite"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/InviteResult"
/admin/account:
get:
operationId: "admin-account-get"
tags: [ Account Management ]
summary: List all accounts.
description: |
Lists all available (internal and external) accounts. An
optional query parameter can be used to narrow the list down
by username. It is a simple substring search in the username
property.
parameters:
- $ref: "#/components/parameters/q"
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AccountList"
post:
operationId: "admin-account-post"
tags: [ Account Management ]
summary: Create a new account.
description: |
Creates a new account. The account is marked as internal and
the provided password is used when authenticating. Sharry
supports external authentication, these accounts however,
cannot be directly created. They are created on demand.
The username and password properties are mandatory. The others
are optional or have a sensible default.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/AccountCreate"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/admin/account/{accountId}:
parameters:
- $ref: "#/components/parameters/accountId"
get:
operationId: "admin-ccount-id-get"
tags: [ Account Management ]
summary: Details about one account.
description: |
Returns details about the account with the given id. Note that
the id is *not* the username, but the account-id.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AccountDetail"
post:
operationId: "admin-account-id-post"
tags: [ Account Management ]
summary: Modify an account.
description: |
Modifies an existing account. It is only possible to modify
`state`, `email` and the `admin` property.
If the `email` property is not supplied, an existing email is
removed from the account.
The password can be changed for an account. If it is `null` or
empty, it is left unchanged. Also, if the account is not
internal, a given password is ignored.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/AccountModify"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
delete:
operationId: "admin-account-id-delete"
tags: [ Account Management ]
summary: Deletes an account.
description: |
Deletes the account and all its related data.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/settings/email:
get:
operationId: "sec-settings-email-get"
tags: [ Account Management ]
summary: Get your E-Mail address.
description: |
Allows the current user to get their e-mail address.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/EmailInfo"
post:
operationId: "sec-settings-email-post"
tags: [ Account Management ]
summary: Edit your E-Mail.
description: |
Allows the current user to change their e-mail address.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/EmailChange"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
delete:
operationId: "sec-settings-email-delete"
tags: [ Account Management ]
summary: Removed your E-Mail.
description: |
Allows the current user to remove their e-mail address.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/settings/password:
get:
operationId: "sec-settings-password-get"
tags: [ Account Management ]
summary: Check for password change.
description: |
Returns wether the current account is available for a password
change. If this returns `false`, the POST request to this url
will always fail.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
post:
operationId: "sec-settings-password-post"
tags: [ Account Management ]
summary: Change your password.
description: |
Allows users to change their password. This is only valid for
internal accounts.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PasswordChange"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/alias:
get:
operationId: "sec-alias-get"
tags: [ Alias ]
summary: List all aliases.
description: |
Lists all aliases of the current user.
parameters:
- $ref: "#/components/parameters/q"
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AliasList"
post:
operationId: "sec-alias-post"
tags: [ Alias ]
summary: Create new alias
description: |
Create a new alias. The id is generated to some random string
if not specified, such that the URLs resulting from this alias
are not guessable.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/AliasChange"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/IdResult"
/sec/alias/{id}:
parameters:
- $ref: "#/components/parameters/id"
get:
operationId: "sec-alias-id-get"
tags: [ Alias ]
summary: Details about one alias.
description: |
Returns details about an alias for the given id.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AliasDetail"
post:
operationId: "sec-alias-id-post"
tags: [ Alias ]
summary: Change an alias
description: |
Change some properties of an existing alias.
The id is optional; if it is not specified a new random one
will be generated.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/AliasChange"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/IdResult"
delete:
operationId: "sec-alias-id-delete"
tags: [ Alias ]
summary: Delete an alias.
description: |
Deletes an alias.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/alias-member:
get:
operationId: "sec-alias-member-get"
tags: [ Alias ]
summary: Get a list of accounts
description: |
Gets a list of accounts suitable for adding them as members to
an alias.
parameters:
- $ref: "#/components/parameters/q"
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/AccountLightList"
/alias/upload:
$ref: "#/paths/~1sec~1upload"
/sec/upload:
post:
operationId: "sec-upload-post"
tags:
- Shares Upload
summary: Upload files to create a share.
description: |
Allows to create a new share by uploading data using
`multipart/form-data` requests. All requests must have content
type `multipart/form-data`.
All parts of a `multipart/form-data` request are treated as
files except if one with name *"meta"* is found. This is
expected to contain a JSON structure with the metadata
(validity, password etc). If this is missing, default values
will be used. All other parts are added as files to the new
share. It is allowed to send only a "meta" part or even an
empty body. In these cases the new share will be created
without files..
If this route is at `/alias/` a `Sharry-Alias` header is
required.
security:
- authTokenHeader: []
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
meta:
$ref: "#/components/schemas/ShareProperties"
file:
type: array
items:
type: string
format: binary
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/IdResult"
/sec/share/search:
get:
operationId: "sec-share-search-get"
tags:
- Shares
summary: Search your shares.
security:
- authTokenHeader: []
description: |
Returns a list of all shares of the current user.
parameters:
- $ref: "#/components/parameters/q"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/ShareList"
/alias/upload/new:
$ref: "#/paths/~1sec~1upload~1new"
/sec/upload/new:
post:
operationId: "sec-upload-new-post"
tags:
- Shares Upload
summary: Create a new empty share.
description: |
This endpoint allows to only upload json data to create a new
empty share.
The same thing can be achieved by using `multipart/form-data`
requests to the `/sec/upload` endpoint containing only one part
named "meta". But this endpoint may be more convenient to use.
If this route is at `/alias/` a `Sharry-Alias` header is
required.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/ShareProperties"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/IdResult"
/open/share/{pid}:
get:
operationId: "open-share-pid-get"
tags:
- Shares (Public)
summary: Get details about a share.
description: |
Returns all details about a share.
If the share is password protected, the password must be
supplied using the header `Sharry-Password`. If it is not
supplied, a 401 response is sent. If it is wrong, a 403
response will be returned.
parameters:
- $ref: "#/components/parameters/pid"
- $ref: "#/components/parameters/SharryPassword"
responses:
401:
description: Unauthorized
403:
description: Forbidden
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/ShareDetail"
/sec/share/{id}:
parameters:
- $ref: "#/components/parameters/id"
get:
operationId: "sec-share-id-get"
tags:
- Shares
summary: Get details about a share.
security:
- authTokenHeader: []
description: |
Returns all details about a share.
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/ShareDetail"
delete:
operationId: "sec-share-id-delete"
tags:
- Shares
summary: Delete a share.
description: |
Allows to delete a share and all associated files.
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/alias/upload/{id}/files/add:
$ref: "#/paths/~1sec~1upload~1%7Bid%7D~1files~1add"
/sec/upload/{id}/files/add:
post:
operationId: "sec-upload-id-files-add"
tags:
- Shares Upload
summary: Add more files to a share.
description: |
This endpoint can be used to add more files to an existing
share. It must be a `multipart/form-data` request, where each
part results in a new file added to the share.
If this route is at `/alias/` a `Sharry-Alias` header is
required.
security:
- authTokenHeader: []
parameters:
- $ref: "#/components/parameters/id"
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: array
items:
type: string
format: binary
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/name:
post:
operationId: "sec-share-id-name-post"
tags:
- Shares
summary: Set a new name.
description: |
Sets the name of the share.
parameters:
- $ref: "#/components/parameters/id"
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SingleString"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
delete:
operationId: "sec-share-id-name-delete"
tags:
- Shares
summary: Deletes the name of a share.
description: |
A name is optional and can be removed via this route.
parameters:
- $ref: "#/components/parameters/id"
security:
- authTokenHeader: []
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/validity:
post:
operationId: "sec-share-id-validity-post"
tags:
- Shares
summary: Set a new validity time.
parameters:
- $ref: "#/components/parameters/id"
security:
- authTokenHeader: []
description: |
Sets the validity property of the share to a new value.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SingleNumber"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/description:
post:
operationId: "sec-share-id-description-post"
tags:
- Shares
summary: Set a new description.
parameters:
- $ref: "#/components/parameters/id"
security:
- authTokenHeader: []
description: |
Sets the description of share.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SingleString"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/maxviews:
post:
operationId: "sec-share-id-maxviews-post"
tags:
- Shares
summary: Set new maximum downloads.
parameters:
- $ref: "#/components/parameters/id"
security:
- authTokenHeader: []
description: |
Sets the maximum downloads property.
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SingleNumber"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/password:
parameters:
- $ref: "#/components/parameters/id"
post:
operationId: "sec-share-id-password-post"
tags:
- Shares
summary: Sets a password to this share.
description: |
Sets or changes the password of the share. If the share
already has a password defined, it must be given with the
request. Otherwise it may be empty.
security:
- authTokenHeader: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SingleString"
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
delete:
operationId: "sec-share-id-password-delete"
tags:
- Shares
summary: Removes the password from the share.
security:
- authTokenHeader: []
description: |
Removes the password that has been set for this share. If this
share has no password set, a successful response is sent.
responses:
422:
description: BadRequest
200:
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/BasicResult"
/sec/share/{id}/publish: