-
Notifications
You must be signed in to change notification settings - Fork 33
/
wforce_api.7.yml
923 lines (923 loc) · 23.1 KB
/
wforce_api.7.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
swagger: "2.0"
info:
version: "2.12.0"
title: "OX Abuse Shield (Wforce)"
description: "An API to the wforce daemon to prevent brute-force and abuse of mail systems"
contact:
name: "Open-Xchange"
license:
name: "GPL3"
url: http://github.com/PowerDNS/weakforced/blob/master/LICENSE
host: "doesnotexist.open-xchange.com"
basePath: "/"
schemes:
- "http"
- "https"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/?command=report:
post:
description: "Creates a new report about a login (successful or unsuccessful)"
operationId: "report"
produces:
- "application/json"
parameters:
- name: "LoginTupleReport"
in: body
description: "Login Tuple for report command"
required: true
schema:
$ref: "#/definitions/LoginTupleReport"
responses:
"200":
description: "report response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=allow:
post:
description: "Query whether a login should be allowed"
operationId: "allow"
produces:
- "application/json"
parameters:
- name: "LoginTupleAllow"
in: body
description: "Login Tuple for allow command"
required: true
schema:
$ref: "#/definitions/LoginTupleAllow"
responses:
"200":
description: "allow response"
schema:
type: object
required:
- status
- msg
- r_attrs
properties:
status:
type: integer
msg:
type: string
r_attrs:
type: object
properties:
attr_name:
type: string
example:
two_factor_required: true
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=reset:
post:
description: "Reset the stats and any blacklist entry for an IP and/or login"
operationId: "reset"
produces:
- "application/json"
parameters:
- name: "Reset"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/ResetStatsParams"
responses:
"200":
description: "reset response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=delBLEntry:
post:
description: "Delete a blacklist entry for an IP and/or login. Note that netmask and ip parameters are mutually exclusive."
operationId: "delBLEntry"
produces:
- "application/json"
parameters:
- name: "delBLEntry"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/DelBLWLEntryParams"
responses:
"200":
description: "delBLEntry response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=addBLEntry:
post:
description: "Add a blacklist entry for an IP and/or login. Note that netmask and ip parameters are mutually exclusive."
operationId: "addBLEntry"
produces:
- "application/json"
parameters:
- name: "addBLEntry"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/AddBLWLEntryParams"
responses:
"200":
description: "addBLEntry response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=delWLEntry:
post:
description: "Delete a whitelist entry for an IP and/or login. Note that netmask and ip parameters are mutually exclusive."
operationId: "delWLEntry"
produces:
- "application/json"
parameters:
- name: "delWLEntry"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/DelBLWLEntryParams"
responses:
"200":
description: "delWLEntry response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=addWLEntry:
post:
description: "Add a whitelist entry for an IP and/or login. Note that netmask and ip parameters are mutually exclusive."
operationId: "addWLEntry"
produces:
- "application/json"
parameters:
- name: "addWLEntry"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/AddBLWLEntryParams"
responses:
"200":
description: "addWLEntry response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=ping:
get:
description: "Ping the server to ensure it is operational"
operationId: "ping"
produces:
- "application/json"
responses:
"200":
description: "ping response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=syncDone:
get:
description: "Tell the server that DB syncing is done"
operationId: "syncDone"
produces:
- "application/json"
responses:
"200":
description: "syncDone response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=stats:
get:
description: "Get server stats (deprecated - will be removed in
future version)"
operationId: "stats"
produces:
- "application/json"
responses:
"200":
description: "stats response"
schema:
$ref: "#/definitions/statsResponse"
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=getBL:
get:
description: "Get the list of all blacklisted IPs and/or Logins"
operationId: "getBL"
produces:
- "application/json"
responses:
"200":
description: "getBL response"
schema:
$ref: "#/definitions/BLWLResponse"
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=getWL:
get:
description: "Get the list of all whitelisted IPs and/or Logins"
operationId: "getWL"
produces:
- "application/json"
responses:
"200":
description: "getWL response"
schema:
$ref: "#/definitions/BLWLResponse"
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=getDBStats:
post:
description: "Get the db stats for an IP and/or login"
operationId: "getDBStats"
produces:
- "application/json"
parameters:
- name: "GetDBStats"
in: body
description: "Provide IP and/or login"
required: true
schema:
$ref: "#/definitions/ResetStatsParams"
responses:
"200":
description: "getDBStats response"
schema:
$ref: "#/definitions/DBStatsResponse"
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=syncDBs:
post:
description: This is a request to synchronize StatsDBs.
operationId: syncDBs
produces:
- application/json
parameters:
- name: "syncDBs"
in: body
description: "The ip and address to sync to"
required: true
schema:
$ref: "#/definitions/syncDBsParams"
responses:
"200":
description: "syncDBs response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=dumpEntries:
post:
description: This is a request to dump StatsDB entries (consisting of the values of each of the time windows for each field) to a specified IP address and port over TCP.
operationId: dumpEntries
produces:
- application/json
parameters:
- name: "dumpEntries"
in: body
description: "The ip and port to dump to"
required: true
schema:
$ref: "#/definitions/dumpEntriesParams"
responses:
"200":
description: "dumpEntries response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=customEndpoint:
post:
description: Extensible mechanism allows custom REST endpoints to be defined - this is an example
operationId: customEndpoint
produces:
- "application/json"
parameters:
- name: CustomFuncArgs
in: body
description: Arguments to custom REST endpoint
required: true
schema:
$ref: "#/definitions/CustomFuncArgs"
responses:
"200":
description: "custom endpoint response"
schema:
type: object
required:
- success
- r_attrs
properties:
success:
type: boolean
r_attrs:
type: object
properties:
attr_name:
type: string
example:
two_factor_required: true
default:
description: unexpected error
schema:
$ref: "#/definitions/CustomError"
/?command=addSibling:
post:
description: This is a request to add a new Sibling for replication purposes.
operationId: addSibling
produces:
- application/json
parameters:
- name: "addSibling"
in: body
description: "Details about the Sibling to add"
required: true
schema:
$ref: "#/definitions/addSiblingParams"
responses:
"200":
description: "addSibling response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=removeSibling:
post:
description: This is a request to add remove a Sibling for replication purposes.
operationId: removeSibling
produces:
- application/json
parameters:
- name: "removeSibling"
in: body
description: "Details about the Sibling to remove"
required: true
schema:
$ref: "#/definitions/removeSiblingParams"
responses:
"200":
description: "removeSibling response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/?command=setSiblings:
post:
description: This is a request to set the Siblings for replication purposes.
operationId: setSiblings
produces:
- application/json
parameters:
- name: "setSiblings"
in: body
description: "Details about the Sibling to add"
required: true
schema:
$ref: "#/definitions/setSiblingsParams"
responses:
"200":
description: "setSiblings response"
schema:
type: object
required:
- status
properties:
status:
type: string
example:
status: ok
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
/metrics:
get:
description: "Retrieve prometheus metrics"
operationId: "metrics"
produces:
- "text/plain"
responses:
"200":
description: "Prometheus metrics in the format described at https://prometheus.io/docs/instrumenting/exposition_formats/"
default:
description: unexpected error
schema:
$ref: "#/definitions/Error"
definitions:
CustomFuncArgs:
required:
- attrs
example:
attrs: { "key":"value" }
properties:
attrs:
$ref: "#/definitions/LTAttrs"
LoginTupleReport:
required:
- login
- remote
- pwhash
- success
example:
login: joe.bloggs
remote: 192.168.1.2
pwhash: cc04
success: true
properties:
login:
type: string
remote:
type: string
pwhash:
type: string
success:
type: boolean
policy_reject:
type: boolean
protocol:
type: string
enum:
- http
- imap
- pop3
- smtp
- mobileapi
tls:
type: boolean
device_id:
type: string
attrs:
$ref: "#/definitions/LTAttrs"
LTAttrs:
type: object
properties:
attr_name_single_value:
type: string
attr_name multi_value:
type: array
items:
type: string
example:
attr1: value1
attr2: value2
attr3: [ value3, value4 ]
LoginTupleAllow:
required:
- login
- remote
- pwhash
properties:
login:
type: string
remote:
type: string
pwhash:
type: string
protocol:
type: string
enum:
- http
- imap
- pop
- smtp
- mobileapi
tls:
type: boolean
device_id:
type: string
attrs:
$ref: "#/definitions/LTAttrs"
example:
login: joe.bloggs
remote: 192.168.1.2
pwhash: cc04
success: true
protocol: http
tls: true
attrs: { "foo":"bar" }
ResetStatsParams:
properties:
ip:
type: string
login:
type: string
example:
ip: 127.0.0.1
DelBLWLEntryParams:
properties:
ip:
type: string
netmask:
type: string
login:
type: string
example:
ip: 127.0.0.1
netmask: 2001:503:ba3e/64
AddBLWLEntryParams:
properties:
ip:
type: string
netmask:
type: string
login:
type: string
expire_secs:
type: integer
reason:
type: string
example:
ip: 127.0.0.1
netmask: 2001:503:ba3e::/64
expire_secs: 3600
reason: "Is there ever a good reason"
CustomError:
required:
- success
- reason
properties:
success:
type: boolean
reason:
type: string
example:
success: false
reason: Unauthorized
Error:
required:
- status
- reason
properties:
status:
type: string
reason:
type: string
example:
status: failure
reason: Unauthorized
BLWLResponse:
type: object
properties:
bl_entries:
type: array
items:
$ref: "#/definitions/BLWLArray"
BLWLArray:
type: object
properties:
ip:
$ref: "#/definitions/BLWLEntry"
login:
$ref: "#/definitions/BLWLEntry"
iplogin:
$ref: "#/definitions/BLWLEntry"
BLWLEntry:
type: array
items:
type: object
properties:
key_name:
type: string
expiration:
type: string
reason:
type: string
example:
login: joe.bloggs
expiration: 2002-Jan-01 10:00:01
reason: Too many invalid login attempts from greylisted countries
DBStatsResponse:
type: object
required:
- key_name
- blacklisted
- stats
properties:
key_name:
type: string
blacklisted:
type: boolean
bl_expire:
type: string
bl_reason:
type: string
whitelisted:
type: boolean
wl_expire:
type: string
wl_reason:
type: string
stats:
$ref: "#/definitions/DBStatsEntry"
DBStatsEntry:
type: object
properties:
db_name:
$ref: "#/definitions/DBStatsFields"
DBStatsFields:
type: object
properties:
field_name:
type: integer
example:
countLogins: 239
diffPassword: 10
statsResponse:
type: object
properties:
reports:
type: integer
allows:
type: integer
denieds:
type: integer
sys-msec:
type: integer
user-msec:
type: integer
perfstats:
type: object
description: Latency buckets for worker thread wait (WTW) and run (WTR)for last 5 minutes
properties:
WTW_0_1:
type: integer
WTW_1_10:
type: integer
WTW_10_100:
type: integer
WTW_100_1000:
type: integer
WTW_Slow:
type: integer
WTR_0_1:
type: integer
WTR_1_10:
type: integer
WTR_10_100:
type: integer
WTR_100_1000:
type: integer
WTR_Slow:
type: integer
commandstats:
type: object
description: Count of REST API commands run in last 5 minutes
properties:
addBLEntry:
type: integer
delBLEntry:
type: integer
getBL:
type: integer
addWLEntry:
type: integer
delWLEntry:
type: integer
getWL:
type: integer
getDBStats:
type: integer
stats:
type: integer
allow:
type: integer
allow_allowed:
type: integer
allow_blacklisted:
type: integer
allow_whitelisted:
type: integer
allow_denied:
type: integer
allow_tarpitted:
type: integer
report:
type: integer
reset:
type: integer
ping:
type: integer
syncDBs:
type: integer
syncDone:
type: integer
customstats:
type: object
description: Count of custom statistics in last 5 minutes
properties:
custom_stat:
type: integer
example:
reports: 28291
allows: 120321
denieds: 20201
sys-msec: 97211221
user-msec: 292910108
perfstats: {"WTR_0_1": 0, "WTR_100_1000": 0, "WTR_10_100": 0, "WTR_1_10": 0, "WTR_Slow": 0, "WTW_0_1": 1, "WTW_100_1000": 0, "WTW_10_100": 0, "WTW_1_10": 0, "WTW_Slow": 0}
commandstats: {"addBLEntry": 0, "addWLEntry": 1, "allow": 8, "allow_allowed": 4, "allow_blacklisted": 0, "allow_denied": 0, "allow_tarpitted": 0, "allow_whitelisted": 4, "delBLEntry": 0, "delWLEntry": 0, "getBL": 0, "getDBStats": 0, "getWL": 0, "ping": 0, "report": 0, "reset": 0, "stats": 3, "syncDBs": 0, "syncDone": 0}
customstats: {"custom1": 0, "custom2": 0}
syncDBsParams:
type: object
required:
- replication_host
- replication_port
- callback_url
- callback_auth_pwd
properties:
replication_host:
type: string
replication_port:
type: integer
callback_url:
type: string
callback_auth_pw:
type: string
encryption_key:
type: string
dumpEntriesParams:
type: object
required:
- dump_host
- dump_port
properties:
dump_host:
type: string
dump_port:
type: integer
addSiblingParams:
type: object
required:
- sibling_host
- sibling_port
properties:
sibling_host:
type: string
sibling_port:
type: integer
sibling_protocol:
type: string
enum: [tcp, udp]
encryption_key:
type: string
removeSiblingParams:
type: object
required:
- sibling_host
- sibling_port
properties:
sibling_host:
type: string
sibling_port:
type: integer
setSiblingsParams:
type: object
properties:
siblings:
type: array
items:
type: object
required:
- sibling_host
- sibling_port
properties:
sibling_host:
type: string
sibling_port:
type: integer
sibling_protocol:
type: string
enum: [ tcp, udp ]
encryption_key:
type: string