-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathNetworkClient.php
More file actions
42 lines (33 loc) · 1.08 KB
/
NetworkClient.php
File metadata and controls
42 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserOIDC\Service;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
class NetworkClient {
private IClient $client;
public function __construct(
IClientService $clientService,
private IConfig $config,
) {
$this->client = $clientService->newClient();
}
private function processOptions(array $options): array {
$oidcSystemConfig = $this->config->getSystemValue('user_oidc', []);
if (isset($oidcSystemConfig['disable_certificate_verification']) && $oidcSystemConfig['disable_certificate_verification'] === true) {
$options['verify'] = false;
}
return $options;
}
public function get(string $uri, array $options = []): IResponse {
return $this->client->get($uri, $this->processOptions($options));
}
public function post(string $uri, array $options = []): IResponse {
return $this->client->post($uri, $this->processOptions($options));
}
}