A free open source IT asset/license management system
Added ->withOptions() for adapters that may need to follow a redirect
snipeb2a1b76137c0
diff --git a/app/SyncAdapters/Addigy/AddigyClient.php b/app/SyncAdapters/Addigy/AddigyClient.phpindex cdc8e35cdf..834d9004ba 100644--- a/app/SyncAdapters/Addigy/AddigyClient.php+++ b/app/SyncAdapters/Addigy/AddigyClient.php@@ -74,6 +74,7 @@ class AddigyClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withHeaders(['client-id' => $this->clientId,'client-secret' => $this->clientSecret,diff --git a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerClient.php b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerClient.phpindex e5702bc4bb..597781cdea 100644--- a/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerClient.php+++ b/app/SyncAdapters/AppleBusinessManager/AppleBusinessManagerClient.php@@ -155,6 +155,7 @@ class AppleBusinessManagerClientprivate function request(): PendingRequest{return Http::baseUrl($this->apiBaseUrl())+ ->withOptions(['allow_redirects' => false])->withToken($this->bearer())->acceptJson()->timeout(30)@@ -177,6 +178,7 @@ class AppleBusinessManagerClient$assertion = $this->buildClientAssertion();$response = Http::asForm()+ ->withOptions(['allow_redirects' => false])->timeout(30)->post(self::APPLE_TOKEN_ENDPOINT, ['grant_type' => 'client_credentials',diff --git a/app/SyncAdapters/AppleBusinessManager/AppleDBImageFetcher.php b/app/SyncAdapters/AppleBusinessManager/AppleDBImageFetcher.phpindex eeca74d350..f79e7aaefd 100644--- a/app/SyncAdapters/AppleBusinessManager/AppleDBImageFetcher.php+++ b/app/SyncAdapters/AppleBusinessManager/AppleDBImageFetcher.php@@ -95,7 +95,8 @@ class AppleDBImageFetcherprivate static function fetchDeviceInfo(string $productType): ?array{try {- $response = Http::timeout(self::REQUEST_TIMEOUT_SECONDS)+ $response = Http::withOptions(['allow_redirects' => false])+ ->timeout(self::REQUEST_TIMEOUT_SECONDS)->acceptJson()->get(self::INFO_HOST.'/device/'.rawurlencode($productType).'.json');} catch (ConnectionException|RequestException $e) {@@ -163,7 +164,8 @@ class AppleDBImageFetcher}try {- $response = Http::timeout(self::REQUEST_TIMEOUT_SECONDS)+ $response = Http::withOptions(['allow_redirects' => false])+ ->timeout(self::REQUEST_TIMEOUT_SECONDS)->get(sprintf('%s/device@main/%s/%s.png', self::IMAGE_HOST, rawurlencode($imageKey), rawurlencode($colorKey)));} catch (ConnectionException|RequestException $e) {Log::channel('sync-adapters')->warning(sprintf(diff --git a/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php b/app/SyncAdapters/CustomHttp/CustomHttpAdapter.phpindex d7da0953dd..9a34cd1c19 100644--- a/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php+++ b/app/SyncAdapters/CustomHttp/CustomHttpAdapter.php@@ -527,7 +527,7 @@ class CustomHttpAdapter extends SyncAdapter implements PushableAdapter*/private function dispatchPushRequest(string $method, string $endpoint, array $payload, array $touched): void{- $request = $this->applyAuth(Http::acceptJson()->timeout(30));+ $request = $this->applyAuth(Http::withOptions(['allow_redirects' => false])->acceptJson()->timeout(30));try {$request->send($method, $endpoint, ['json' => $payload])->throw();@@ -763,7 +763,7 @@ class CustomHttpAdapter extends SyncAdapter implements PushableAdapter$endpoint = $baseUrl.$pullPath;}- $request = Http::acceptJson()->timeout(30);+ $request = Http::withOptions(['allow_redirects' => false])->acceptJson()->timeout(30);$request = $this->applyAuth($request);// ->throw() propagates on non-2xx so the controller can catchdiff --git a/app/SyncAdapters/Fleet/FleetClient.php b/app/SyncAdapters/Fleet/FleetClient.phpindex 044ee12ca6..20181a02d7 100644--- a/app/SyncAdapters/Fleet/FleetClient.php+++ b/app/SyncAdapters/Fleet/FleetClient.php@@ -117,6 +117,7 @@ class FleetClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/Intune/IntuneClient.php b/app/SyncAdapters/Intune/IntuneClient.phpindex 10dd5d7c68..73dd22f9be 100644--- a/app/SyncAdapters/Intune/IntuneClient.php+++ b/app/SyncAdapters/Intune/IntuneClient.php@@ -71,6 +71,7 @@ class IntuneClient$tokenUrl = rtrim($this->loginBaseUrl, '/').'/'.$this->tenantId.'/oauth2/v2.0/token';$response = Http::asForm()+ ->withOptions(['allow_redirects' => false])->timeout(30)->post($tokenUrl, ['grant_type' => 'client_credentials',@@ -98,6 +99,7 @@ class IntuneClient$url = rtrim($this->graphBaseUrl, '/').'/beta/deviceManagement/managedDevices/'.$deviceId;Http::withToken($this->bearer())+ ->withOptions(['allow_redirects' => false])->asJson()->acceptJson()->timeout(30)@@ -108,6 +110,7 @@ class IntuneClientprivate function request(): PendingRequest{return Http::withToken($this->bearer())+ ->withOptions(['allow_redirects' => false])->acceptJson()->timeout(30);}diff --git a/app/SyncAdapters/Jamf/JamfClient.php b/app/SyncAdapters/Jamf/JamfClient.phpindex 2c870416df..91e4f6a017 100644--- a/app/SyncAdapters/Jamf/JamfClient.php+++ b/app/SyncAdapters/Jamf/JamfClient.php@@ -101,6 +101,7 @@ class JamfClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/JamfSchool/JamfSchoolClient.php b/app/SyncAdapters/JamfSchool/JamfSchoolClient.phpindex d8815a75f0..5692d59dc2 100644--- a/app/SyncAdapters/JamfSchool/JamfSchoolClient.php+++ b/app/SyncAdapters/JamfSchool/JamfSchoolClient.php@@ -82,6 +82,7 @@ class JamfSchoolClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withBasicAuth($this->networkId, $this->apiKey)->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/JumpCloud/JumpCloudClient.php b/app/SyncAdapters/JumpCloud/JumpCloudClient.phpindex baac53050d..22fd64e583 100644--- a/app/SyncAdapters/JumpCloud/JumpCloudClient.php+++ b/app/SyncAdapters/JumpCloud/JumpCloudClient.php@@ -61,6 +61,7 @@ class JumpCloudClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withHeaders(['x-api-key' => $this->apiKey])->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/Kandji/KandjiClient.php b/app/SyncAdapters/Kandji/KandjiClient.phpindex 58d1d9173d..d52c21a954 100644--- a/app/SyncAdapters/Kandji/KandjiClient.php+++ b/app/SyncAdapters/Kandji/KandjiClient.php@@ -98,6 +98,7 @@ class KandjiClientpublic function updateDevice(string $deviceId, array $fields): void{Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->asForm()@@ -109,6 +110,7 @@ class KandjiClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Client.php b/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Client.phpindex 4caa20e4b3..34c0f1c0e6 100644--- a/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Client.php+++ b/app/SyncAdapters/KaseyaVsa10/KaseyaVsa10Client.php@@ -141,6 +141,7 @@ class KaseyaVsa10Clientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/').'/api/v3')+ ->withOptions(['allow_redirects' => false])->withHeaders(['Authorization' => 'Basic '.$this->basicAuth()])->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/MerakiSystemsManager/MerakiClient.php b/app/SyncAdapters/MerakiSystemsManager/MerakiClient.phpindex 5ef589a303..b0f1c3bd6a 100644--- a/app/SyncAdapters/MerakiSystemsManager/MerakiClient.php+++ b/app/SyncAdapters/MerakiSystemsManager/MerakiClient.php@@ -105,6 +105,7 @@ class MerakiClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withHeaders(['X-Cisco-Meraki-API-Key' => $this->apiKey])->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/Mosyle/MosyleClient.php b/app/SyncAdapters/Mosyle/MosyleClient.phpindex 3f259540c6..d107b6ab9e 100644--- a/app/SyncAdapters/Mosyle/MosyleClient.php+++ b/app/SyncAdapters/Mosyle/MosyleClient.php@@ -126,6 +126,7 @@ class MosyleClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->asJson()diff --git a/app/SyncAdapters/NinjaOne/NinjaOneClient.php b/app/SyncAdapters/NinjaOne/NinjaOneClient.phpindex 04ac9a7119..0310e26779 100644--- a/app/SyncAdapters/NinjaOne/NinjaOneClient.php+++ b/app/SyncAdapters/NinjaOne/NinjaOneClient.php@@ -77,6 +77,7 @@ class NinjaOneClient}$response = Http::asForm()+ ->withOptions(['allow_redirects' => false])->timeout(30)->post(rtrim($this->baseUrl, '/').'/ws/oauth/token', ['grant_type' => 'client_credentials',@@ -111,6 +112,7 @@ class NinjaOneClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->bearer())->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/Osctrl/OsctrlClient.php b/app/SyncAdapters/Osctrl/OsctrlClient.phpindex 08e4b3f4c2..859c26c2e8 100644--- a/app/SyncAdapters/Osctrl/OsctrlClient.php+++ b/app/SyncAdapters/Osctrl/OsctrlClient.php@@ -52,6 +52,7 @@ class OsctrlClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->token)->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/Unifi/UnifiClient.php b/app/SyncAdapters/Unifi/UnifiClient.phpindex c530267454..0503f36673 100644--- a/app/SyncAdapters/Unifi/UnifiClient.php+++ b/app/SyncAdapters/Unifi/UnifiClient.php@@ -72,6 +72,7 @@ class UnifiClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withHeaders(['X-API-KEY' => $this->apiKey])->acceptJson()->timeout(30);diff --git a/app/SyncAdapters/WorkspaceOne/WorkspaceOneClient.php b/app/SyncAdapters/WorkspaceOne/WorkspaceOneClient.phpindex 747a82d71f..a28e359e72 100644--- a/app/SyncAdapters/WorkspaceOne/WorkspaceOneClient.php+++ b/app/SyncAdapters/WorkspaceOne/WorkspaceOneClient.php@@ -76,6 +76,7 @@ class WorkspaceOneClient}$response = Http::asForm()+ ->withOptions(['allow_redirects' => false])->timeout(30)->post(rtrim($this->authBaseUrl, '/').'/connect/token', ['grant_type' => 'client_credentials',@@ -130,6 +131,7 @@ class WorkspaceOneClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->apiBaseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withToken($this->bearer())->withHeaders(['aw-tenant-code' => $this->tenantCode])->acceptJson()diff --git a/app/SyncAdapters/Zentral/ZentralClient.php b/app/SyncAdapters/Zentral/ZentralClient.phpindex 63fd2a9e19..4f7393819a 100644--- a/app/SyncAdapters/Zentral/ZentralClient.php+++ b/app/SyncAdapters/Zentral/ZentralClient.php@@ -58,6 +58,7 @@ class ZentralClientprivate function request(): PendingRequest{return Http::baseUrl(rtrim($this->baseUrl, '/'))+ ->withOptions(['allow_redirects' => false])->withHeaders(['Authorization' => 'Token '.$this->token])->acceptJson()->timeout(30);