upgrade to laravel 7 and set branch to v2

This commit is contained in:
2020-12-25 11:22:15 +00:00
parent 516105c492
commit 0ddd298350
4638 changed files with 132501 additions and 190226 deletions

View File

@@ -11,6 +11,8 @@
namespace Symfony\Component\HttpKernel;
use Symfony\Component\HttpFoundation\Request;
/**
* Signs URIs.
*
@@ -37,11 +39,9 @@ class UriSigner
* The given URI is signed by adding the query string parameter
* which value depends on the URI and the secret.
*
* @param string $uri A URI to sign
*
* @return string The signed URI
*/
public function sign($uri)
public function sign(string $uri)
{
$url = parse_url($uri);
if (isset($url['query'])) {
@@ -59,11 +59,9 @@ class UriSigner
/**
* Checks that a URI contains the correct hash.
*
* @param string $uri A signed URI
*
* @return bool True if the URI is signed correctly, false otherwise
*/
public function check($uri)
public function check(string $uri)
{
$url = parse_url($uri);
if (isset($url['query'])) {
@@ -82,6 +80,14 @@ class UriSigner
return hash_equals($this->computeHash($this->buildUrl($url, $params)), $hash);
}
public function checkRequest(Request $request): bool
{
$qs = ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : '';
// we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering)
return $this->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().$qs);
}
private function computeHash(string $uri): string
{
return base64_encode(hash_hmac('sha256', $uri, $this->secret, true));