-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
executable file
·609 lines (404 loc) · 13.7 KB
/
apiary.apib
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
# SHM v1 API
FORMAT: 1A
## About SHM
TODO
## API Requests
TODO
## Modify Login form
TODO
## Return codes
HTTP 401, 403, 500,
503 - Restart in progress
TODO
## Your own theme recomendations
Our theme is free under GNU license, you can modify and use them at your own themes.
We used AngularJS and Bootstrap for them.
For using your own theme just upload theme files to `html/MyOwnTheme` folder inside panel homedir and
add theme name to main config `etc/main.conf` at `[Core]` section to `Themes`.
First theme in the list will be default theme for all users. Default language is `EN`.
For example:
```
[Core]
Themes = ["MyOwnTheme", "Simple"]
```
Service restart needed to reload config.
# Data Structures
## Error (object)
+ error (required,object)
## Files (object)
+ Dir (required, boolean) - Is dir.
+ Name (required, string) - Name of the dir or file.
+ Size (required, number) - Size in bytes.
+ Permissions (required, number) - Permissions.
+ Owner (required, number) - Owner of file or dir.
+ Group (required, number) - Group of file or dir.
+ Modified (required, string) - Date time of last modification.
# Group Remove testing user regularUser
## #AuthRoot for testing user removing [POST /login]
+ Request (application/json)
{
"Login": "root",
"Password": "$ROOT_PASSWORD"
}
+ Response 200 (application/json)
{
"Auth": "Logged",
"Theme": "Simple",
"Language": "EN"
}
## Removing testing user regularUser [POST /api/users/del]
+ Request (application/json)
{
"Name":"$USER_NAME"
}
+ Response 204 (text/plain)
## Logout from Root [GET /logout]
+ Response 204 (text/plain)
# Group Create regularUser for tests
## #AuthRoot for testing user creation [POST /login]
+ Request (application/json)
{
"Login": "root",
"Password": "$ROOT_PASSWORD"
}
+ Response 200 (application/json)
{
"Auth": "Logged",
"Theme": "Simple",
"Language": "EN"
}
## Create testing user regularUser [POST /api/users/set]
+ Request (application/json)
{
"Username":"$USER_NAME",
"Password":"$USER_PASSWORD",
"Info":{
"Active":true,
"Comment":"Just a testing user",
"Template":"SimpleUser",
"Email":"root@localhost",
"Theme":"Alpha",
"Language":"EN",
"HOTP":{
"Active":false
}
}
}
+ Response 204 (text/plain)
## Logout from Root [GET /logout]
+ Response 204 (text/plain)
# Group Panel Authorization
First of all you must login into panel as `root` to gain administrator privileges or as a regular user.
For login you must use your credentials of user or root login and password if you are the server administrator.
## User login [/login]
For login you must use your credentials of a user that was registered by the `root` in a panel.
+ Attributes
+ Login (required,string) - User's login, which is email or root for admin.
+ Password (required,string) - User defined password or root password for admin.
+ Hotp (optional, string) - Code from two step authorization app.
+ Auth (string) - Authorization status.
### Login fails [POST]
If login and password is not correct you will receive `403 Forbidden`.
Debug information about login, user not found or wrong password are in the system's log file.
+ Request (application/json)
{
"Login": "$USER_NAME",
"Password": "wrongUserPassword"
}
+ Response 403 (application/json)
{
"Auth": "Denied"
}
### Login success #AuthUser [POST]
If login and(or) password is correct you will receive success login response with
`Theme` is a GUI theme, `Language` is a user defined interface language.
Login script do redirect to `https://server:port/Theme` to load GUI for theme.
+ Attributes
+ Theme:Simple (required, string) - User defined GUI theme.
+ Language:EN (required, string) - User defined language for GUI.
+ Request (application/json)
{
"Login": "$USER_NAME",
"Password": "$USER_PASSWORD"
}
+ Response 200 (application/json)
{
"Auth": "Logged",
"Theme": "Simple",
"Language": "EN"
}
### HOTP code required [POST]
How to [turn on two step authorization](two-step-authorization)
If user turned on two step authorization from Google Authenticator or other HOTP compatible mobile app,
HOTP code must be present along with login and password fields.
You need to repeat login request with HOTP code from user's mobile app.
+ Request (application/json)
{
"Login": "hotpUser",
"Password": "hotpUserSecretPassword"
}
+ Response 449 (application/json)
{
"Auth": "HOTP required"
}
### Login with HOTP success [POST]
If HOTP code from user's app correct, you'll receive `200` and `Login success` reply.
+ Attributes
+ HOTP (required, string) - Code from device for two step authorization.
+ Request (application/json)
{
"Login": "hotpUser",
"Password": "hotpUserSecretPassword",
"Hotp":"12345"
}
+ Response 200 (application/json)
{
"Auth": "Logged",
"Theme": "Simple",
"Language": "EN"
}
### Login fails because HOTP wrong code [POST]
In case of wrong HOTP code `403` would be received.
You can send another request with correct HOTP code.
+ Request (application/json)
{
"Login": "hotpUser",
"Password": "hotpUserSecretPassword",
"Hotp":"54321"
}
+ Response 403 (application/json)
{
"Auth": "HOTP wrong code"
}
## Root login [/login]
For login you must use your root system password and login `root`.
### Root login fails [POST]
If password is not correct you will receive `403 Forbidden`.
+ Request (application/json)
{
"Login": "root",
"Password": "wrongPassword"
}
+ Response 403 (application/json)
{
"Auth": "Denied"
}
### Root login success #AuthRoot [POST]
+ Attributes
+ Theme:Simple (required, string) - User defined GUI theme.
+ Language:EN (required, string) - User defined language for GUI.
+ Request (application/json)
{
"Login": "root",
"Password": "$ROOT_PASSWORD"
}
+ Response 200 (application/json)
{
"Auth": "Logged",
"Theme": "Simple",
"Language": "EN"
}
# Group Create Test environment
Creating test environment.
## Add MySQL test user as #User [POST /api/mysql/users/set]
Add test user for PgSQL dumps.
+ Request (application/json)
{
"Username":"DBUser1",
"Password":"NewMyDBUserPassword",
"Host":"localhost"
}
+ Response 204 (text/plain)
## Add PgSQL test user as #User [POST /api/pgsql/users/set]
Add test user for PgSQL dumps.
+ Request (application/json)
{
"Username":"DbTester",
"Password":"NewMyDBTesterPassword"
}
+ Response 204 (text/plain)
## Add PGSQL db for Import as #User [POST /api/pgsql/db/set]
+ Request (application/json)
{
"DbName":"DbImport",
"DbUser":"DbTester"
}
+ Response 204 (text/plain)
## Create test.html file by Root [POST /api/filemanager/editfile]
Create /var/www/test.html by Root.
+ Request (application/json)
{
"Filename": "/var/www/test.html",
"Encoding": "ISO 8859-2",
"Text":"<h1>Hello world!</h1>"
}
+ Response 204 (text/plain)
## Create /test.html file by #User [POST /api/filemanager/editfile]
Create /home/USER/test.html by User.
+ Request (application/json)
{
"Filename": "/test.html",
"Encoding": "ISO 8859-2",
"Text":"<h1>Hello world!</h1>"
}
+ Response 204 (text/plain)
## Create from_root.html in user's dir by Root [POST /api/filemanager/editfile]
+ Request (application/json)
{
"Filename": "/home/regularUser/from_root.html",
"Encoding": "ISO 8859-2",
"Text":"<h3>Created by root!</h3>"
}
+ Response 204 (text/plain)
## Create dirs for TAR archive testing as Root [POST /api/filemanager/mkdir]
+ Request (application/json)
{
"Dir": "/var/www",
"Mkdir": "test_archives/tar"
}
+ Response 204 (text/plain)
## Create dirs for ZIP archive testing as Root [POST /api/filemanager/mkdir]
+ Request (application/json)
{
"Dir": "/var/www",
"Mkdir": "test_archives/zip"
}
+ Response 204 (text/plain)
## Create dir for TAR archive testing as #User [POST /api/filemanager/mkdir]
+ Request (application/json)
{
"Dir": "/www",
"Mkdir": "test_archives/tar"
}
+ Response 204 (text/plain)
## Add test.com domain as #User [POST /api/webdomains/set]
+ Request (application/json)
{
"Name":"$TESTING_DOMAIN",
"Active":true,
"Alias":"www.$TESTING_DOMAIN site.$TESTING_DOMAIN",
"Ip":"$SERVER_IP",
"IndexFile":"index.html",
"Encoding":"utf8",
"Subdomains":true,
"PHP":"fpm_nginx",
"DNS":true,
"SSL":false,
"Analytics":true
}
+ Response 204 (text/plain)
## Add [email protected] Email box as #User [POST /api/email/set]
+ Request (application/json)
{
"Email":"info@$TESTING_DOMAIN",
"Alias":"",
"Size":500,
"Password":"infoPassword"
}
+ Response 204 (text/plain)
## Generate DKIM record for [email protected] as #User [POST /api/dkim/set]
+ Request (application/json)
{
"Domain":"$TESTING_DOMAIN"
}
+ Response 204 (text/plain)
# Group Two step authorization
For using two step authorization you can install **Google Authenticator** or other mobile app that support HOTP protocol.
There are two ways to add your app for two step authorization:
* Enter generated code at your mobile Google Authenticator app,
* Scan generated QR code on your mobile Google Authenticator app,
For proper QR generation you need to get code first and only after that make request to generate QR.
## Generate code for enter by hand [/api/hotp/code]
This request will generate one time code that you need to enter while add new account to Google Authenticator app.
### Getting key code [GET]
Generate one time key code.
+ Attributes
+ Key (required,string) - One time generated key for app binding.
+ Response 200 (application/json)
{
"Key": "12368615794617"
}
## Generate QR [/api/hotp/qr]
This request will generate one time code that you need to save in your Google Authenticator app.
### Getting QR image with code [GET]
Generate PNG image with QR code you can scan by Google Authenticator to add account.
+ Response 200 (image/jpeg)
## Check for correct app binding [/api/hotp/check]
Before two step authorization cat be enabled we need to check if everything is good.
You need to enter first generated code from your app.
### HOTP app Code correct [POST]
+ Request (application/json)
{
"Confirm": "95726283"
}
+ Response 204 (text/plain)
### HOTP app Wrong code [POST]
If app was not binded properly, first code was not accepted.
+ Request (application/json)
{
"Confirm": "7324545"
}
+ Response 406 (text/plain)
## HOTP toggle [/api/hotp/toggle]
!TODO
# Group FTP accounts
PFTPD server accounts.
## Add or Edit FTP account [POST /api/pftpd/set]
Add or edit FTP accounts.
+ Attributes
+ UserID (required, string) - FTP account login name.
+ Password (required, string) - FTP account password.
+ User (optional, string) - Panel user which owns FTP account. Only `root` can set User.
+ Homedir (required, string) - FTP directory path related to current user's homedir.
+ Request (application/json)
{
"UserID": "FTP1",
"Password" : "FTPPassword",
"Homedir": "/www/$TESTING_DOMAIN/"
}
+ Response 204 (text/plain)
## List FTP accounts [GET /api/pftpd/list]
List all user's FTP account.
+ Response 200 (application/json)
[
{
"UserID":"$USER_NAME_FTP1",
"Homedir": "/www/$TESTING_DOMAIN/"
}
]
## !Hook FTP account testing [GET /hook]
Test FTP account by ftp client
+ Response 299
## Remove FTP accounts [POST /api/pftpd/del]
Remove FTP accounts.
+ Request (application/json)
["FTP1"]
+ Response 204 (text/plain)
## Remove non existent ftp account #Error [POST /api/pftpd/del]
+ Request (application/json)
["FTPNotExist"]
+ Response
# Group Remove Test environment
Remove test environment.
## Remove dirs for ZIP archive testing as Root [POST /api/filemanager/del]
+ Request (application/json)
[
"/var/www/test_archives/zip"
]
+ Response 204 (text/plain)
## Remove dirs for TAR archive testing as Root [POST /api/filemanager/del]
+ Request (application/json)
[
"/var/www/test_archives/tar"
]
+ Response 204 (text/plain)
# Group Logout
To close current session user can logout by request. This is not necessary but recommended to close the session.
If user is inactive for 1800 seconds, session will be destroyed by the panel itself.
You can change this value in config file at `GHttp.SessionLifeTime`.
## #User logout [GET /logout]
Close the regular user session.
+ Response 204 (text/plain)
## Root logout [GET /logout]
Administrator `root` session close.
+ Response 204 (text/plain)