Files
Netbox-Store/store/public/index.php
T
MrBlake f36d6be511
CI / php-store (push) Waiting to run
CI / python-components (push) Waiting to run
feat: add NetBox plugin store
2026-08-24 20:51:25 +02:00

41 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
// Web responses never expose PHP diagnostics; errors are logged and the
// application returns a generic error page/JSON envelope.
ini_set('display_errors', '0');
ini_set('display_startup_errors', '0');
ini_set('log_errors', '1');
header_remove('X-Powered-By');
use NetBoxStore\Config;
use NetBoxStore\Database\RepositoryFactory;
use NetBoxStore\Http\Application;
use NetBoxStore\Http\Request;
use NetBoxStore\Security\Auth;
use NetBoxStore\Security\HttpClient;
use NetBoxStore\Security\SsrfGuard;
use NetBoxStore\Sync\SyncService;
$root = dirname(__DIR__);
require $root . '/vendor/autoload.php';
$config = Config::load($root);
$repository = RepositoryFactory::create($config);
$repository->initialize();
$request = Request::fromGlobals($config);
$guard = new SsrfGuard($config);
$http = new HttpClient($config, $guard);
$sync = new SyncService($repository, $config, $http, $guard);
$sync->ensureDefaultSource();
$auth = new Auth($config, $repository);
$adminPath = $request->path === '/admin' || str_starts_with($request->path, '/admin/');
if ($auth->enabled() && $adminPath) {
// Public catalog/API/health traffic must not allocate anonymous sessions.
$auth->startSession();
}
$application = new Application($config, $repository, $auth, $sync, $guard);
$application->handle($request)->send();