mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
get csrf token in request; Test for prefix 'http-' in csrf token header
This commit is contained in:
@@ -68,7 +68,7 @@ class BaseCsrfVerifier implements IMiddleware
|
||||
|
||||
$token = $request->getInputHandler()->value(
|
||||
static::POST_KEY,
|
||||
$request->getHeader(static::HEADER_KEY),
|
||||
$request->getHeader(static::HEADER_KEY) ?? $request->getHeader('HTTP-' . static::HEADER_KEY),
|
||||
'post'
|
||||
);
|
||||
|
||||
|
||||
@@ -147,6 +147,15 @@ class Request
|
||||
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
|
||||
* @return array
|
||||
|
||||
Reference in New Issue
Block a user