From 398fc70ad81e71951105c4a950be0f8c4024bd01 Mon Sep 17 00:00:00 2001 From: davide.cucurnia@vola.it <davide.cucurnia@vola.it> Date: Thu, 01 Feb 2024 09:04:57 +0100 Subject: [PATCH] aggiunti metodi getSelectedMSISDNDetails, getMSISDNList, getMSISDNDetails per picasso --- app/Http/Controllers/FakeResponder/FakeResponder.php | 46 ++++++++++++++++++---------------------------- 1 files changed, 18 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/FakeResponder/FakeResponder.php b/app/Http/Controllers/FakeResponder/FakeResponder.php index d5307c2..c67f0c6 100644 --- a/app/Http/Controllers/FakeResponder/FakeResponder.php +++ b/app/Http/Controllers/FakeResponder/FakeResponder.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use App\Vola\Services\VolaFakeHTTPResponder\VolaFakeHTTPResponder; use Illuminate\Http\Request; -use Illuminate\Support\Str; +use App\Vola\Classes\Utils; class FakeResponder extends Controller { @@ -14,7 +14,6 @@ public string $cookieFakePicassoName = "SSOSESSIONID"; public array $headers; public VolaFakeHTTPResponder $VolaFakeSSO; - protected bool $openFakeSSO = true; function __construct() { @@ -29,45 +28,36 @@ public function manageLegacyRequest(Request $request) { + $this->logReceivedRequest($request); if (isset($_COOKIE[$this->cookieFakeSSOName])) { - $testUser = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakeSSOName])); - $responseContent = $this->VolaFakeSSO->getResponses($request, $testUser); + $profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakeSSOName])); + $responseContent = $this->VolaFakeSSO->getResponses($request, $profile); - $this->logRequest($request, $responseContent, "SSO Legacy"); - $responseContent = (config('custom.compressed_responses',false) === TRUE) ? gzencode($responseContent, 3) : $responseContent; + $this->logProcessedRequest($request, $responseContent, "SSO Legacy"); + $responseContent = $this->compressIfRequested($request, $responseContent); + return response($responseContent, 200, $this->headers); + } else { - \Log::channel('requests_failed')->debug($request->url() . "\nNessun cookie di sessione ".$this->cookieFakeSSOName); - return response('No cookie', 400, $this->headers); + $this->logRejectedRequest($request); + return response('No cookie, no logged', 400, $this->headers); } } public function managePicassoRequest(Request $request) { + $this->logReceivedRequest($request); if (isset($_COOKIE[$this->cookieFakePicassoName])) { - $testUser = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakePicassoName])); - $responseContent = $this->VolaFakeSSO->getResponses($request, $testUser, true); + $profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakePicassoName])); + $responseContent = $this->VolaFakeSSO->getResponses($request, $profile, true); - $this->logRequest($request, $responseContent, "Picasso"); - $responseContent = (config('custom.compressed_responses',false) === TRUE) ? gzencode($responseContent, 3) : $responseContent; + $this->logProcessedRequest($request, $responseContent, "Picasso"); + $responseContent = $this->compressIfRequested($request, $responseContent); + return response($responseContent, 200, $this->headers); } else { - \Log::channel('requests_failed')->debug("Picasso " . $request->url() . "\nNessun cookie di sessione ".$this->cookieFakePicassoName); - return response('No cookie', 400, $this->headers); - } - } - - public function logRequest(Request $request, $responseContent = null, $system = '') - { - if (config('custom.log_all_requests', true) === TRUE) { - $uriParts = explode("?", $request->url()); - $methodUri = Str::afterLast($uriParts[0], "/"); - $reqParams = !empty($request->query()) ? $request->query() : []; - //\Log::channel('requests_managed')->debug($system . " " . $request->getClientIp() ." ". $methodUri . " with params ".print_r($reqParams,1)); - //\Log::channel('requests_managed')->debug("Cookies received: " . print_r($_COOKIE,1)); - if (isset($responseContent)) { - \Log::channel('requests_managed')->debug("\n" . $system . " " . $request->getClientIp() . " " . $methodUri . " :\n" . print_r($responseContent, 1)); - } + $this->logRejectedRequest($request); + return response('No cookie no logged', 400, $this->headers); } } -- Gitblit v1.8.0