Использование и настройка локального API CrowdSec

, . CrowdSec — , IP- . -, , , , CrowdSec . .



CrowdSec 1.x API, , , .

?



API . , , . API .



? , IP- , . , . , API, CrowdSec.



API , push- , . , API — . CrowdSec , , « », .



API



, CrowdSec (CLI). — API.



. , CrowdSec, -, , , :



cscli bouncers add BouncerdeTest







:







, . — :



cscli machines add MachinedeTest –auto











yaml, .







, . , API :



cscli lapi register -u <api_url>







, , API. :



cscli machines validate MachinedeTest







:







API



API HTTP-. . , HTTPS.







API , 2 :



(getDecisions)



API , IP-, IP-, .



API ( Curl), IP:



curl -H "X-Api-Key: e73e3672427ecd8cd9a6487f7e8f4f03" http://localhost:8080/v1/decisions?ip=98.65.32.47







, API ?ip, IP-, .



JSON, :



[{"duration":"2h25m47.212560128s","id":1023,"origin":"cscli","scenario":"manual 'ban' from '939972095cf1459c8b22cc608eff85daEb4yoi2wiTD7Y3fA'","scope":"Ip","type":"ban","value":"1.2.3.4"}]







?range, , , , scope+value , .



curl -H "X-Api-Key: e73e3672427ecd8cd9a6487f7e8f4f03" http://localhost:8080/v1/decisions?scope=username&value=korben







.



(getDecisionsStream)



, , .



, , , API ?Startup «true», :



curl -s -H "X-Api-Key: e73e3672427ecd8cd9a6487f7e8f4f03" http://localhost:8080/v1/decisions/stream?startup=true







?startup «false» , .



{
  "deleted": null,
  "new": [
    {
      "duration": "3h59m57.641708614s",
      "id": 2410,
      "origin": "cscli",
      "scenario": "manual 'ban' from '939972095cf1459c8b22cc608eff85daEb4yoi2wiTD7Y3fA'",
      "scope": "Ip",
      "type": "ban",
      "value": "3.3.3.4"
    }
  ]
}

      
      





, «null»:




{
  "deleted": null,
  "new": null
}

      
      





API Watcher (cscli CrowdSec)



, API . API (POST/DELETE) (GET) CrowdSec, .







, , IP, :



curl -X DELETE "https://localhost:8080/v1/decisions?ip=98.65.32.47" -H "accept: application/json"







, , .



, , CrowdSec Github , Go, , API.







API .





, API CrowdSec . Go . . Nginx, WordPress, HAProxy, iptables, nftables Amazon (AWS) Google (Network FW Cloud Armor). Github. LUA PHP.



, , , , CrowdSec.



All Articles