From ca5063d95a6bff7991d9d5f512e403f9a6663828 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Tue, 22 Nov 2022 16:02:04 -0500 Subject: [PATCH] Log API Authorization failed errors --- Civi/API/Kernel.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Civi/API/Kernel.php b/Civi/API/Kernel.php index acbebe7020..ed09dce093 100644 --- a/Civi/API/Kernel.php +++ b/Civi/API/Kernel.php @@ -144,7 +144,16 @@ class Kernel { $this->boot($apiRequest); [$apiProvider, $apiRequest] = $this->resolve($apiRequest); - $this->authorize($apiProvider, $apiRequest); + + try { + $this->authorize($apiProvider, $apiRequest); + } + catch (\Civi\API\Exception\UnauthorizedException $e) { + // We catch and re-throw to log for visibility + \CRM_Core_Error::backtrace('API Request Authorization failed', TRUE); + throw $e; + } + [$apiProvider, $apiRequest] = $this->prepare($apiProvider, $apiRequest); $result = $apiProvider->invoke($apiRequest); -- 2.25.1