Move integration credentials into encrypted dashboard settings
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 1m42s

This commit is contained in:
Hickmeister
2026-10-11 16:15:02 +01:00
parent 96561dc3d2
commit ff9960fe06
23 changed files with 493 additions and 41 deletions
+26 -5
View File
@@ -7,10 +7,31 @@ use RuntimeException;
class DryerClient
{
public function __construct(private IntegrationSettings $settings) {}
public function configured(): bool
{
$settings = $this->settings->for('dryer');
return filled($settings['url'] ?? null) && filled($settings['api_key'] ?? null);
}
public function dashboardUrl(): string
{
$url = rtrim((string) ($this->settings->for('dryer')['url'] ?? ''), '/');
return preg_replace('#/api/v1$#', '', $url) ?? $url;
}
private function apiKey(): string
{
return (string) ($this->settings->for('dryer')['api_key'] ?? '');
}
private function url(string $path): string
{
$base = config('services.dryer.url');
if (! $base || ! config('services.dryer.api_key')) {
$base = $this->settings->for('dryer')['url'] ?? null;
if (! $this->configured()) {
throw new RuntimeException('Dryer URL and API key must be configured.');
}
@@ -24,13 +45,13 @@ class DryerClient
public function status(): array
{
return Http::withHeaders(['X-API-Key' => config('services.dryer.api_key')])->acceptJson()
return Http::withHeaders(['X-API-Key' => $this->apiKey()])->acceptJson()
->connectTimeout(3)->timeout(7)->get($this->url('status'))->throw()->json() ?? [];
}
public function history(): array
{
return Http::withHeaders(['X-API-Key' => config('services.dryer.api_key')])->acceptJson()
return Http::withHeaders(['X-API-Key' => $this->apiKey()])->acceptJson()
->connectTimeout(3)->timeout(7)->get($this->url('history'), ['limit' => 60])->throw()->json() ?? [];
}
@@ -53,7 +74,7 @@ class DryerClient
private function command(string $path, array $payload = []): array
{
return Http::withHeaders(['X-API-Key' => config('services.dryer.api_key')])->acceptJson()
return Http::withHeaders(['X-API-Key' => $this->apiKey()])->acceptJson()
->connectTimeout(3)->timeout(7)->post($this->url($path), [
'requestId' => 'dashboard-'.bin2hex(random_bytes(12)), ...$payload,
])->throw()->json() ?? [];