mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-10 23:52:14 +00:00
Merge branch 'get-csrf-token' of https://github.com/DeveloperMarius/simple-php-router into DeveloperMarius-get-csrf-token
This commit is contained in:
@@ -64,11 +64,11 @@ class BaseCsrfVerifier implements IMiddleware
|
|||||||
public function handle(Request $request): void
|
public function handle(Request $request): void
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->skip($request) === false && \in_array($request->getMethod(), ['post', 'put', 'delete'], true) === true) {
|
if ($this->skip($request) === false && \in_array($request->getMethod(), ['post', 'put', 'patch', 'delete'], true) === true) {
|
||||||
|
|
||||||
$token = $request->getInputHandler()->value(
|
$token = $request->getInputHandler()->value(
|
||||||
static::POST_KEY,
|
static::POST_KEY,
|
||||||
$request->getHeader(static::HEADER_KEY),
|
$request->getHeader(static::HEADER_KEY) ?? $request->getHeader('HTTP-' . static::HEADER_KEY),
|
||||||
'post'
|
'post'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,15 @@ class Request
|
|||||||
return $this->getHeader('php-auth-pw');
|
return $this->getHeader('php-auth-pw');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the csrf token
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getCsrfToken(): ?string
|
||||||
|
{
|
||||||
|
return $this->getHeader('x-csrf-token') ?? $this->getHeader('http-x-csrf-token');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all headers
|
* Get all headers
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
Reference in New Issue
Block a user