upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 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
* @return string
*/
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
* @return bool
*/
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));