1
0

settings.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. use Monolog\Level;
  4. $appEnv = getenv('APP_ENV') ?: 'production';
  5. if ($appEnv === 'development' && file_exists(__DIR__ . '/../.env')) {
  6. $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
  7. $dotenv->safeLoad();
  8. }
  9. $logLevelName = strtoupper((string) (getenv('LOG_LEVEL') ?: 'info'));
  10. $logLevel = match ($logLevelName) {
  11. 'DEBUG' => Level::Debug,
  12. 'NOTICE' => Level::Notice,
  13. 'WARNING' => Level::Warning,
  14. 'ERROR' => Level::Error,
  15. 'CRITICAL' => Level::Critical,
  16. 'ALERT' => Level::Alert,
  17. 'EMERGENCY' => Level::Emergency,
  18. default => Level::Info,
  19. };
  20. $truthy = static fn (string $env, bool $default = false): bool => match (strtolower((string) (getenv($env) ?: ''))) {
  21. 'true', '1', 'yes', 'on' => true,
  22. 'false', '0', 'no', 'off' => false,
  23. '' => $default,
  24. default => $default,
  25. };
  26. return [
  27. 'app_env' => $appEnv,
  28. 'log_level' => $logLevel,
  29. 'public_url' => getenv('PUBLIC_URL') ?: 'http://localhost:8080',
  30. 'ui_secret' => getenv('UI_SECRET') ?: '',
  31. // BFF — talking to the api
  32. 'api_base_url' => getenv('API_BASE_URL') ?: '',
  33. 'ui_service_token' => getenv('UI_SERVICE_TOKEN') ?: '',
  34. 'api_timeout_seconds' => (float) (getenv('API_TIMEOUT_SECONDS') ?: 5),
  35. // OIDC — Microsoft Entra ID by default
  36. 'oidc_enabled' => $truthy('OIDC_ENABLED', true),
  37. 'oidc_issuer' => getenv('OIDC_ISSUER') ?: '',
  38. 'oidc_client_id' => getenv('OIDC_CLIENT_ID') ?: '',
  39. 'oidc_client_secret' => getenv('OIDC_CLIENT_SECRET') ?: '',
  40. 'oidc_redirect_uri' => getenv('OIDC_REDIRECT_URI') ?: '',
  41. // Local admin (UI-side credentials only)
  42. 'local_admin_enabled' => $truthy('LOCAL_ADMIN_ENABLED', true),
  43. 'local_admin_username' => getenv('LOCAL_ADMIN_USERNAME') ?: 'admin',
  44. 'local_admin_password_hash' => getenv('LOCAL_ADMIN_PASSWORD_HASH') ?: '',
  45. // Session: 8h inactivity, 24h absolute
  46. 'session_idle_seconds' => (int) (getenv('SESSION_IDLE_SECONDS') ?: 28800),
  47. 'session_absolute_seconds' => (int) (getenv('SESSION_ABSOLUTE_SECONDS') ?: 86400),
  48. // GeoIP — only the provider name. The UI uses it to pick the right
  49. // attribution string for the IP-detail enrichment panel. The api
  50. // owns the actual provider config; this is a display-only mirror.
  51. 'geoip_provider' => strtolower((string) (getenv('GEOIP_PROVIDER') ?: 'dbip')),
  52. ];