Pflege Adresse und Zugangsschlüssel der Shinkan-Anbindung in der Verwaltung
Werte aus der Umgebung des Servers haben Vorrang, sonst gilt der in der Verwaltung gepflegte. Der Schlüssel liegt verschlüsselt in site_settings und wird nie angezeigt. Änderung nur für Katalog- und Systemverwalter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bcda189267
commit
26ca79cd22
8 files changed
+320
-17
No files matched your search
@@ -34,22 +34,25 @@ class ShinkanImport
|
||||
|
||||
public function configured(): bool
|
||||
{
|
||||
return filled(config('services.shinkan.url')) && filled(config('services.shinkan.key'));
|
||||
return app(ShinkanConnection::class)->configured();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zustand der Anbindung ohne Werte: Adresse und Schlüssel stehen nur in der Umgebungsdatei des Servers.
|
||||
* Zustand der Anbindung ohne Werte: ob Adresse und Schlüssel vorhanden sind und woher sie kommen.
|
||||
*
|
||||
* @return array{url: bool, key: bool, host: string|null}
|
||||
* @return array{url: bool, key: bool, host: string|null, url_source: string|null, key_source: string|null}
|
||||
*/
|
||||
public function status(): array
|
||||
{
|
||||
$url = (string) config('services.shinkan.url');
|
||||
$connection = app(ShinkanConnection::class);
|
||||
$url = $connection->url();
|
||||
|
||||
return [
|
||||
'url' => filled($url),
|
||||
'key' => filled(config('services.shinkan.key')),
|
||||
'host' => filled($url) ? (parse_url($url, PHP_URL_HOST) ?: null) : null,
|
||||
'url' => $url !== null,
|
||||
'key' => $connection->apiKey() !== null,
|
||||
'host' => $url !== null ? (parse_url($url, PHP_URL_HOST) ?: null) : null,
|
||||
'url_source' => $connection->source('url'),
|
||||
'key_source' => $connection->source('key'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ public function status(): array
|
||||
public function check(): array
|
||||
{
|
||||
if (! $this->configured()) {
|
||||
return ['ok' => false, 'message' => 'Die Anbindung ist nicht eingerichtet. Adresse und Schlüssel fehlen in der Umgebung des Servers.'];
|
||||
return ['ok' => false, 'message' => 'Die Anbindung ist nicht eingerichtet. Adresse und Zugangsschlüssel fehlen.'];
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -81,7 +84,7 @@ public function fetch(): ExerciseImportRun
|
||||
$run = ExerciseImportRun::query()->create(['status' => 'laeuft', 'started_at' => now()]);
|
||||
|
||||
if (! $this->configured()) {
|
||||
return $this->finish($run, 'fehler', error: 'Die Anbindung ist nicht eingerichtet. Adresse und Schlüssel fehlen in der Umgebung.');
|
||||
return $this->finish($run, 'fehler', error: 'Die Anbindung ist nicht eingerichtet. Adresse und Zugangsschlüssel fehlen.');
|
||||
}
|
||||
|
||||
$previous = ExerciseImportRun::query()->where('status', 'ok')->orderByDesc('id')->value('cursor');
|
||||
@@ -340,10 +343,11 @@ private function createComposition(string $title, string $summary): Composition
|
||||
*/
|
||||
private function get(string $path, array $query = []): array
|
||||
{
|
||||
$response = Http::withToken((string) config('services.shinkan.key'))
|
||||
$connection = app(ShinkanConnection::class);
|
||||
$response = Http::withToken((string) $connection->apiKey())
|
||||
->acceptJson()
|
||||
->timeout(20)
|
||||
->get(rtrim((string) config('services.shinkan.url'), '/').'/api/distribution/v1'.$path, $query)
|
||||
->get((string) $connection->url().'/api/distribution/v1'.$path, $query)
|
||||
->throw();
|
||||
|
||||
$json = $response->json();
|
||||
|
||||
Reference in new issue
Block a user