mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-25 21:25:21 +02:00
refactor: implement middleware chain (#4240)
* refactor: implement middleware chain * refactor
This commit is contained in:
parent
e7ae06dcf0
commit
39952c2d95
7 changed files with 128 additions and 61 deletions
21
middlewares/SecurityMiddleware.php
Normal file
21
middlewares/SecurityMiddleware.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Make sure that only strings are allowed in GET parameters
|
||||
*/
|
||||
class SecurityMiddleware implements Middleware
|
||||
{
|
||||
public function __invoke(Request $request, $next): Response
|
||||
{
|
||||
foreach ($request->toArray() as $key => $value) {
|
||||
if (!is_string($value)) {
|
||||
return new Response(render(__DIR__ . '/../templates/error.html.php', [
|
||||
'message' => "Query parameter \"$key\" is not a string.",
|
||||
]), 400);
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue