Skip to content

Commit 0eaa601

Browse files
feat(*): Prepare release 0.31.0
1 parent 2b6ba78 commit 0eaa601

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.31.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.31.0) - 2022-09-23
8+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.30.0...v0.31.0)
9+
10+
### Changed
11+
- Use Twig as template engine for ban and captcha walls
12+
13+
---
714

815
## [0.30.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.30.0) - 2022-09-22
916
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.29.0...v0.30.0)

src/Bouncer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function getRemediationForIp(string $ip): string
151151
}
152152

153153
/**
154-
* Returns a default "CrowdSec 403" HTML template to display to a web browser using a banned IP.
154+
* Returns a default "CrowdSec 403" HTML template.
155155
* The input $config should match the TemplateConfiguration input format.
156156
*
157157
* @param array $config An array of template configuration parameters
@@ -170,8 +170,14 @@ public static function getAccessForbiddenHtmlTemplate(array $config): string
170170
}
171171

172172
/**
173-
* Returns a default "CrowdSec Captcha" HTML template to display to a web browser using a captchable IP.
173+
* Returns a default "CrowdSec Captcha (401)" HTML template.
174174
* The input $config should match the TemplateConfiguration input format.
175+
*
176+
* @param bool $error
177+
* @param string $captchaImageSrc
178+
* @param string $captchaResolutionFormUrl
179+
* @param array $config
180+
* @return string
175181
*/
176182
public static function getCaptchaHtmlTemplate(
177183
bool $error,

src/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Constants
2020
public const DEFAULT_LAPI_URL = 'http://localhost:8080';
2121

2222
/** @var string The last version of this library */
23-
public const VERSION = 'v0.30.0';
23+
public const VERSION = 'v0.31.0';
2424

2525
/** @var string The user agent used to send request to LAPI */
2626
public const BASE_USER_AGENT = 'PHP CrowdSec Bouncer/' . self::VERSION;

src/Template.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace CrowdSecBouncer;
44

5+
use Twig\Error\LoaderError;
6+
use Twig\Error\RuntimeError;
7+
use Twig\Error\SyntaxError;
58
use Twig\Loader\FilesystemLoader;
69
use Twig\Environment;
710
use Twig\TemplateWrapper;
@@ -21,6 +24,14 @@ class Template
2124
/** @var TemplateWrapper */
2225
private $template;
2326

27+
/**
28+
* @param string $path
29+
* @param string $templatesDir
30+
* @param array $options
31+
* @throws LoaderError
32+
* @throws RuntimeError
33+
* @throws SyntaxError
34+
*/
2435
public function __construct(string $path, string $templatesDir = Constants::TEMPLATES_DIR, array $options = [])
2536
{
2637
$loader = new FilesystemLoader($templatesDir);

0 commit comments

Comments
 (0)