|
| 1 | + |
| 2 | +<p align="center"> |
| 3 | +<img src="https://raw.githubusercontent.com/crowdsecurity/crowdsec/master/docs/assets/images/crowdsec_logo.png" alt="CrowdSec" title="CrowdSec" width="200" height="120"/> |
| 4 | +</p> |
| 5 | + |
1 | 6 | # PHP Bouncer Library
|
2 | 7 |
|
3 |
| -The official PHP client for the CrowdSec APIs (LAPI or CAPI). |
| 8 | +> The official PHP bouncer library for the CrowdSec LAPI/CAPI |
| 9 | +
|
| 10 | +<p align="center"> |
| 11 | +<img src="https://img.shields.io/github/workflow/status/crowdsecurity/php-cs-bouncer/tests/main"> |
| 12 | +<img src="https://img.shields.io/github/license/crowdsecurity/php-cs-bouncer"> |
| 13 | +<img src="https://img.shields.io/github/v/release/crowdsecurity/php-cs-bouncer?include_prereleases"> |
| 14 | +</p> |
| 15 | + |
| 16 | +<p align="center"> |
| 17 | +:books: <a href="https://doc.crowdsec.net">Documentation</a> |
| 18 | +:diamond_shape_with_a_dot_inside: <a href="https://hub.crowdsec.net">Hub</a> |
| 19 | +:speech_balloon: <a href="https://discourse.crowdsec.net">Discourse Forum</a> |
| 20 | +:speech_balloon: <a href="https://gitter.im/crowdsec-project/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link">Gitter Chat</a> |
| 21 | +</p> |
| 22 | + |
| 23 | +> This library allows you to create CrowdSec bouncers for PHP applications or frameworks like e-commerce, blog or other exposed applications. |
4 | 24 |
|
5 |
| -This client helps to create CrowdSec bouncers for PHP applications or frameworks (e-commerce, blog, other apps...). |
| 25 | +## Features |
6 | 26 |
|
| 27 | +- ✅ Fast API client |
| 28 | +- ✅ LAPI Support (CAPI not supported yet) |
| 29 | +- ✅ Built-in support for the most known cache systems like Redis, Memcached, PhpFiles |
| 30 | +- ✅ **Live mode** or **Stream mode** |
| 31 | +- ✅ Events logged using monolog |
| 32 | +- ✅ Large PHP matrix compatibility: 7.2.x, 7.3.x, 7.4.x and 8.0.x |
| 33 | +- ✅ Cap remediation level (ex: for sensitives websites: ban will be capped to captcha) |
| 34 | +- ✅ Clear and prune the cache |
7 | 35 | ## Getting started
|
8 | 36 |
|
9 |
| -View `docs/getting-started.md` to learn how to include this library in your project. |
| 37 | +### Installing CrowdSec Bouncer library |
| 38 | + |
| 39 | +The recommended way to install CrowdSec Bouncer library is through [Composer](https://getcomposer.org/). |
| 40 | + |
| 41 | +```bash |
| 42 | +composer require crowdsec/bouncer |
| 43 | +``` |
| 44 | + |
| 45 | +```php |
| 46 | + |
| 47 | +/* To get a token: "cscli bouncers add <name-of-your-php-bouncer> */ |
| 48 | +$apiToken = 'YOUR_TOKEN'; |
| 49 | + |
| 50 | +/* Select the best cache adapter for your needs (Memcached, Redis, PhpFiles, ...) */ |
| 51 | +$cacheAdapter = new Symfony\Component\Cache\Adapter\PhpFilesAdapter(); |
10 | 52 |
|
11 |
| -You will find the full documenation here: (...) TODO P2 |
| 53 | +$bouncer = new CrowdSecBouncer\Bouncer(); |
| 54 | +$bouncer->configure(['api_token'=> $apiToken], $cacheAdapter); |
12 | 55 |
|
13 |
| -# Sources |
| 56 | +$remediation = $bouncer->getRemediationForIp($blockedIp);// Return "ban", "captcha" or "bypass" |
| 57 | +``` |
14 | 58 |
|
15 |
| -- https://thephp.website/en/issue/php-docker-quick-setup/ |
| 59 | +View [`docs/getting-started.md`](https://github.com/crowdsecurity/php-cs-bouncer/blob/main/docs/getting-started.rst) to learn how to include this library in your project in minutes. |
16 | 60 |
|
17 |
| -# Licence |
| 61 | +## Future |
| 62 | +- Retrieve cache items with pagination |
| 63 | +- Release 1.0.0 version |
| 64 | +- Direct CAPI support |
| 65 | +- Support more cache systems (Apcu, Couchbase, Doctrine, Pdo) |
| 66 | +- Publish load tests (compare performances) |
| 67 | +- Report Code coverage |
| 68 | +- Setup Xdebug environment with Docker |
18 | 69 |
|
19 |
| -MIT License. Details in the `./LICENSE` file. |
| 70 | +## Licence |
20 | 71 |
|
21 |
| -# TODO |
| 72 | +[MIT License](https://github.com/crowdsecurity/php-cs-bouncer/blob/main/LICENSE) |
22 | 73 |
|
23 |
| -Features: |
24 |
| -- [x] Fast API client |
25 |
| -- [x] LAPI Support |
26 |
| -- [x] Built-in support for the most known cache systems: Redis, Memcached, PhpFiles |
27 |
| -- [x] Live mode |
28 |
| -- [x] Stream mode |
29 |
| -- [x] Log events using monolog |
30 |
| -- [x] PHP compatibility with 7.2.x, 7.3.x, 7.4.x and 8.0.x |
31 |
| -- [ ] Cap remediation level (ex: for sensitives websites: ban will be capped to captcha) |
32 |
| -- [ ] Retrieve cache items with pagination |
33 |
| -- [ ] Direct CAPI support |
34 |
| -- [ ] Release 1.0.0 version |
35 |
| -- [ ] Support more cache systems (Apcu, Couchbase, Doctrine, Pdo) |
| 74 | +## Licence |
36 | 75 |
|
37 |
| -Code: |
38 |
| -- [x] Docker dev environment (Dockerized Crowdsec, Redis, Memcached, PHP) |
39 |
| -- [x] Continuous Integration (CI, includes Integration Tests and Super Linter) |
40 |
| -- [x] Integration tests (with TDD) |
41 |
| -- [x] Documented (Static documentation, PHP Doc) |
42 |
| -- [ ] Continuous Delivery (CD) |
43 |
| -- [ ] Load tests (compare performances) |
44 |
| -- [ ] Report Code coverage |
45 |
| -- [ ] Setup Xdebug environment |
| 76 | +[MIT License](https://github.com/crowdsecurity/php-cs-bouncer/blob/main/LICENSE) |
0 commit comments