Move subnav menus into top-bar, apply Predictalytics glassmorphism design, add project edit and safe deletion modal, secure license deactivation, add API Swagger docs, and add Watchdog entity hierarchy tree with full CRUD
This commit is contained in:
@@ -5,12 +5,14 @@ declare(strict_types=1);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Core/Db.php';
|
||||
require_once __DIR__ . '/../../../../src/Core/Auth.php';
|
||||
require_once __DIR__ . '/../../../../src/Modules/License/Audit.php';
|
||||
require_once __DIR__ . '/../../../../src/Modules/License/KeyGen.php';
|
||||
require_once __DIR__ . '/../../../../src/Modules/License/RateLimiter.php';
|
||||
require_once __DIR__ . '/../../../../src/Modules/License/LicenseService.php';
|
||||
|
||||
use Deploymentcenter\Core\Db;
|
||||
use Deploymentcenter\Core\Auth;
|
||||
use Deploymentcenter\Modules\License\LicenseService;
|
||||
use Deploymentcenter\Modules\License\RateLimiter;
|
||||
|
||||
@@ -38,18 +40,36 @@ try {
|
||||
|
||||
$licenseService = new LicenseService($pdo);
|
||||
|
||||
// Validate Endpoint (Public API for clients)
|
||||
if (str_ends_with($uri, '/validate') && $method === 'POST') {
|
||||
$res = $licenseService->validate($inputData, $ip);
|
||||
sendResponse($res);
|
||||
}
|
||||
|
||||
// Deactivate Endpoint (AUTHENTICATED ONLY - Security Protection)
|
||||
if (str_ends_with($uri, '/deactivate') && $method === 'POST') {
|
||||
$authHeader = $_SERVER['HTTP_X_WATCHDOG_KEY'] ?? $_SERVER['HTTP_AUTHORIZATION'] ?? $_SERVER['HTTP_X_LICENSE_KEY'] ?? null;
|
||||
if ($authHeader && str_starts_with($authHeader, 'Bearer ')) {
|
||||
$authHeader = substr($authHeader, 7);
|
||||
}
|
||||
|
||||
$sharedKey = $config['security']['shared_key'] ?? '';
|
||||
$isAuthenticated = ($authHeader && hash_equals($sharedKey, $authHeader)) || Auth::isLoggedIn();
|
||||
|
||||
if (!$isAuthenticated) {
|
||||
sendResponse([
|
||||
'error' => 'Unauthorized',
|
||||
'message' => 'Authentication required for license deactivation. Pass Bearer token or master key.'
|
||||
], 401);
|
||||
}
|
||||
|
||||
$res = $licenseService->deactivate($inputData, $ip);
|
||||
sendResponse($res);
|
||||
}
|
||||
|
||||
// Status Endpoint
|
||||
if (str_ends_with($uri, '/status') && $method === 'GET') {
|
||||
sendResponse(['status' => 'ok', 'module' => 'LicenseLabrador', 'version' => '1.0']);
|
||||
sendResponse(['status' => 'ok', 'module' => 'Lizenzen', 'version' => '1.0']);
|
||||
}
|
||||
|
||||
sendResponse(['error' => 'Not Found', 'message' => 'Endpoint not found'], 404);
|
||||
|
||||
+512
-404
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user