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
+6 -4
View File
@@ -11,7 +11,7 @@ class Etsy
{
private const API_URL = 'https://api.etsy.com/v3';
/** @var array{keystring: ?string, shared_secret: ?string}|null */
/** @var array{keystring: ?string, shared_secret: ?string, shop_name: string, redirect_uri: ?string}|null */
private ?array $credentials = null;
public function configured(): bool
@@ -51,7 +51,7 @@ class Etsy
if (empty($shop['shop_id'])) {
throw new RuntimeException('This Etsy account does not own a shop.');
}
if (strcasecmp($shop['shop_name'] ?? '', config('services.etsy.shop_name', 'HickLab3D')) !== 0) {
if (strcasecmp($shop['shop_name'] ?? '', $this->credentials()['shop_name']) !== 0) {
throw new RuntimeException('The Etsy account does not own the configured HickLab3D shop.');
}
@@ -108,10 +108,10 @@ class Etsy
public function redirectUri(): string
{
return config('services.etsy.redirect_uri') ?: route('etsy.callback');
return $this->credentials()['redirect_uri'] ?: route('etsy.callback');
}
/** @return array{keystring: ?string, shared_secret: ?string} */
/** @return array{keystring: ?string, shared_secret: ?string, shop_name: string, redirect_uri: ?string} */
private function credentials(): array
{
if ($this->credentials !== null) {
@@ -123,6 +123,8 @@ class Etsy
return $this->credentials = [
'keystring' => $stored?->keystring ?: config('services.etsy.keystring'),
'shared_secret' => $stored?->shared_secret ?: config('services.etsy.shared_secret'),
'shop_name' => $stored?->shop_name ?: config('services.etsy.shop_name', 'HickLab3D'),
'redirect_uri' => $stored?->redirect_uri ?: config('services.etsy.redirect_uri'),
];
}
}