feat: implement core router configuration check method for improved validation
This commit is contained in:
@@ -1606,9 +1606,8 @@ class Firewall extends Component
|
||||
string $protocol
|
||||
): array {
|
||||
try {
|
||||
// Check if Core Router is configured
|
||||
$coreRouterEnabled = \Illuminate\Support\Facades\Config::get('corerouter.enabled', false);
|
||||
if (!$coreRouterEnabled) {
|
||||
// Check if Core Router is configured using the same logic as Statistics component
|
||||
if (!$this->coreRouterEnabled()) {
|
||||
return [
|
||||
'connections' => [],
|
||||
'error' => 'Core Router is not configured'
|
||||
@@ -1773,6 +1772,26 @@ class Firewall extends Component
|
||||
}
|
||||
}
|
||||
|
||||
protected function coreRouterEnabled(): bool
|
||||
{
|
||||
$baseUrl = config('corerouter.base_url');
|
||||
$apiKey = config('corerouter.api_key');
|
||||
$username = config('corerouter.username');
|
||||
$password = config('corerouter.password');
|
||||
|
||||
// Check if base_url is configured and not empty
|
||||
$hasBaseUrl = !empty(trim((string) $baseUrl));
|
||||
|
||||
// Check if API key is configured (not empty after trimming)
|
||||
$hasKey = !empty(trim((string) $apiKey));
|
||||
|
||||
// Check if basic auth credentials are both configured
|
||||
$hasBasic = !empty(trim((string) $username)) && !empty(trim((string) $password));
|
||||
|
||||
// Configuration is valid if base_url is set and at least one auth method is configured
|
||||
return $hasBaseUrl && ($hasKey || $hasBasic);
|
||||
}
|
||||
|
||||
protected function extractIpFromField(string $field): string
|
||||
{
|
||||
if (empty($field)) {
|
||||
|
||||
Reference in New Issue
Block a user