Skip to content

Commit

Permalink
Update security class
Browse files Browse the repository at this point in the history
  • Loading branch information
voltan committed Nov 3, 2024
1 parent 8808efd commit a9f2799
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
15 changes: 12 additions & 3 deletions data/user.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ return [
'date_pattern' => 'dd/MM/yyyy',
],
'security' => [
// Request
'ip' => [
'is_active' => true,
'whitelist' => [
Expand Down Expand Up @@ -178,12 +179,20 @@ return [
'max_requests' => 100,
'rate_limit' => 60, // Time window in seconds
],
'account' => [
'attempts' => 5,
'ttl' => 3600,
// Response
'header' => [
'is_active' => true,
],
'escape' => [
'is_active' => true,
],
'compress' => [
'is_active' => true,
],
// Account
'account' => [
'attempts' => 5,
'ttl' => 3600,
],
],
];
17 changes: 12 additions & 5 deletions src/Middleware/SecurityMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,17 @@ protected function securityRequestList(): array

protected function securityResponseList(): array
{
return [
'header' => new ResponseHeaders($this->config),
'escape' => new ResponseEscape($this->config),
'compress' => new ResponseCompress($this->config),
];
$list = [];
if (isset($this->config['header']['is_active']) && $this->config['header']['is_active']) {
$list['header'] = new ResponseHeaders($this->config);
}
if (isset($this->config['escape']['is_active']) && $this->config['escape']['is_active']) {
$list['escape'] = new ResponseEscape($this->config);
}
if (isset($this->config['compress']['is_active']) && $this->config['compress']['is_active']) {
$list['compress'] = new ResponseCompress($this->config);
}

return $list;
}
}

0 comments on commit a9f2799

Please sign in to comment.