feat: add NetBox plugin store
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?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();
|
||||
Reference in New Issue
Block a user