| | |
| | | namespace App\Http\Controllers\FakeResponder; |
| | | |
| | | use App\Http\Controllers\Controller; |
| | | use App\Http\Requests\genericPicasso; |
| | | use App\Vola\Services\VolaFakeHTTPResponder\VolaFakeHTTPResponder; |
| | | use Illuminate\Http\Request; |
| | | use Illuminate\Support\Str; |
| | | use App\Vola\Classes\Utils; |
| | | |
| | | class FakeResponder extends Controller |
| | | { |
| | |
| | | |
| | | public function manageLegacyRequest(Request $request) |
| | | { |
| | | $this->logReceivedRequest($request); |
| | | if (isset($_COOKIE[$this->cookieFakeSSOName])) { |
| | | $profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakeSSOName])); |
| | | $responseContent = $this->VolaFakeSSO->getResponses($request, $profile); |
| | | |
| | | $this->logProcessedRequest($request, $responseContent, "SSO Legacy"); |
| | | $responseContent = (config('custom.compressed_responses',false) === TRUE) ? gzencode($responseContent, 3) : $responseContent; |
| | | $responseContent = $this->compressIfRequested($request, $responseContent); |
| | | |
| | | return response($responseContent, 200, $this->headers); |
| | | |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | public function managePicassoRequest(Request $request) |
| | | public function managePicassoRequest(genericPicasso $request) |
| | | { |
| | | $this->logReceivedRequest($request); |
| | | if (isset($_COOKIE[$this->cookieFakePicassoName])) { |
| | | $profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakePicassoName])); |
| | | $responseContent = $this->VolaFakeSSO->getResponses($request, $profile, true); |
| | | |
| | | $this->logProcessedRequest($request, $responseContent, "Picasso"); |
| | | $responseContent = (config('custom.compressed_responses',false) === TRUE) ? gzencode($responseContent, 3) : $responseContent; |
| | | $responseContent = $this->compressIfRequested($request, $responseContent); |
| | | |
| | | return response($responseContent, 200, $this->headers); |
| | | } else { |
| | | $this->logRejectedRequest($request); |
| | | return response('No cookie no logged', 400, $this->headers); |
| | | } |
| | | } |
| | | |
| | | public function logProcessedRequest(Request $request, $responseContent = null, $system = '') |
| | | { |
| | | if (config('custom.log_all_requests', true) === TRUE) { |
| | | $uriParts = explode("?", $request->url()); |
| | | $methodUri = Str::afterLast($uriParts[0], "/"); |
| | | if (isset($responseContent)) { |
| | | \Log::channel('requests_managed')->debug("\n" . $system . " " . $request->getClientIp() . " " . $methodUri . " :\n" . print_r($responseContent, 1)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public function logRejectedRequest(Request $request, ?array $additionalInfo = null) |
| | | { |
| | | if (config('custom.log_rejected_requests', true) === TRUE) { |
| | | \Log::channel('requests_failed')->debug("Picasso " . $request->url() . "\nNessun cookie di sessione " . print_r($additionalInfo, 1)); |
| | | } |
| | | } |
| | | |