chore: pint

This commit is contained in:
Benjamin Nussbaum 2025-08-26 11:17:09 +02:00
parent 25f36eaf54
commit 4c66761baa
12 changed files with 142 additions and 121 deletions

View file

@ -2,7 +2,9 @@
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Laravel\Socialite\Facades\Socialite;
class OidcTestCommand extends Command
@ -31,7 +33,7 @@ class OidcTestCommand extends Command
// Check if OIDC is enabled
$enabled = config('services.oidc.enabled');
$this->line("OIDC Enabled: " . ($enabled ? '✅ Yes' : '❌ No'));
$this->line('OIDC Enabled: '.($enabled ? '✅ Yes' : '❌ No'));
// Check configuration values
$endpoint = config('services.oidc.endpoint');
@ -40,11 +42,11 @@ class OidcTestCommand extends Command
$redirect = config('services.oidc.redirect');
$scopes = config('services.oidc.scopes', []);
$this->line("OIDC Endpoint: " . ($endpoint ? "{$endpoint}" : '❌ Not set'));
$this->line("Client ID: " . ($clientId ? "{$clientId}" : '❌ Not set'));
$this->line("Client Secret: " . ($clientSecret ? '✅ Set' : '❌ Not set'));
$this->line("Redirect URL: " . ($redirect ? "{$redirect}" : '❌ Not set'));
$this->line("Scopes: " . (empty($scopes) ? '❌ Not set' : '✅ ' . implode(', ', $scopes)));
$this->line('OIDC Endpoint: '.($endpoint ? "{$endpoint}" : '❌ Not set'));
$this->line('Client ID: '.($clientId ? "{$clientId}" : '❌ Not set'));
$this->line('Client Secret: '.($clientSecret ? '✅ Set' : '❌ Not set'));
$this->line('Redirect URL: '.($redirect ? "{$redirect}" : '❌ Not set'));
$this->line('Scopes: '.(empty($scopes) ? '❌ Not set' : '✅ '.implode(', ', $scopes)));
$this->newLine();
@ -53,38 +55,45 @@ class OidcTestCommand extends Command
// Only test driver if we have basic configuration
if ($endpoint && $clientId && $clientSecret) {
$driver = Socialite::driver('oidc');
$this->line("OIDC Driver: ✅ Successfully registered and accessible");
$this->line('OIDC Driver: ✅ Successfully registered and accessible');
if ($enabled) {
$this->info("✅ OIDC is fully configured and ready to use!");
$this->line("You can test the login flow at: /auth/oidc/redirect");
$this->info('✅ OIDC is fully configured and ready to use!');
$this->line('You can test the login flow at: /auth/oidc/redirect');
} else {
$this->warn("⚠️ OIDC driver is working but OIDC_ENABLED is false.");
$this->warn('⚠️ OIDC driver is working but OIDC_ENABLED is false.');
}
} else {
$this->line("OIDC Driver: ✅ Registered (configuration test skipped due to missing values)");
$this->warn("⚠️ OIDC driver is registered but missing required configuration.");
$this->line("Please set the following environment variables:");
if (!$enabled) $this->line(" - OIDC_ENABLED=true");
if (!$endpoint) {
$this->line(" - OIDC_ENDPOINT=https://your-oidc-provider.com (base URL)");
$this->line(" OR");
$this->line(" - OIDC_ENDPOINT=https://your-oidc-provider.com/.well-known/openid-configuration (full URL)");
$this->line('OIDC Driver: ✅ Registered (configuration test skipped due to missing values)');
$this->warn('⚠️ OIDC driver is registered but missing required configuration.');
$this->line('Please set the following environment variables:');
if (! $enabled) {
$this->line(' - OIDC_ENABLED=true');
}
if (! $endpoint) {
$this->line(' - OIDC_ENDPOINT=https://your-oidc-provider.com (base URL)');
$this->line(' OR');
$this->line(' - OIDC_ENDPOINT=https://your-oidc-provider.com/.well-known/openid-configuration (full URL)');
}
if (! $clientId) {
$this->line(' - OIDC_CLIENT_ID=your-client-id');
}
if (! $clientSecret) {
$this->line(' - OIDC_CLIENT_SECRET=your-client-secret');
}
if (!$clientId) $this->line(" - OIDC_CLIENT_ID=your-client-id");
if (!$clientSecret) $this->line(" - OIDC_CLIENT_SECRET=your-client-secret");
}
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
if (str_contains($e->getMessage(), 'Driver [oidc] not supported')) {
$this->error("❌ OIDC Driver registration failed: Driver not supported");
$this->error('❌ OIDC Driver registration failed: Driver not supported');
} else {
$this->error("❌ OIDC Driver error: " . $e->getMessage());
$this->error('❌ OIDC Driver error: '.$e->getMessage());
}
} catch (\Exception $e) {
$this->warn("⚠️ OIDC Driver registered but configuration error: " . $e->getMessage());
} catch (Exception $e) {
$this->warn('⚠️ OIDC Driver registered but configuration error: '.$e->getMessage());
}
$this->newLine();
return Command::SUCCESS;
}
}