Refactor UI with purple dark theme glassmorphism, projects management, license editing, agent installer scripts, unmaskable tokens, C# test suite

This commit is contained in:
Deploymentcenter Bot
2026-08-05 21:55:19 +02:00
parent 8ddcbf179a
commit fe9f95584e
8 changed files with 813 additions and 276 deletions
+4 -4
View File
@@ -43,8 +43,8 @@ class LicenseService
return array_merge($base, $extra);
};
// 1. Fetch Product
$stmt = $this->db->prepare('SELECT id, default_cache_ttl_hours FROM license_products WHERE slug = :slug');
// 1. Fetch Project from dc_projects
$stmt = $this->db->prepare('SELECT id, default_cache_ttl_hours FROM dc_projects WHERE slug = :slug');
$stmt->execute([':slug' => $productSlug]);
$product = $stmt->fetch();
if (!$product) {
@@ -53,7 +53,7 @@ class LicenseService
'key_prefix' => substr($licenseKey, 0, 5),
'ip' => $clientIp
]);
return $makePayload('not_found', ['message' => 'Product not found']);
return $makePayload('not_found', ['message' => 'Project not found']);
}
$cacheTtlHours = (int)$product['default_cache_ttl_hours'];
@@ -155,7 +155,7 @@ class LicenseService
SELECT a.id, a.license_id
FROM license_activations a
JOIN license_licenses l ON a.license_id = l.id
JOIN license_products p ON l.product_id = p.id
JOIN dc_projects p ON l.product_id = p.id
WHERE p.slug = :slug AND l.license_key = :key AND a.hardware_id = :hw_id
');
$stmt->execute([':slug' => $productSlug, ':key' => $licenseKey, ':hw_id' => $hardwareId]);
+2 -3
View File
@@ -47,8 +47,8 @@ class MonitorRepo
source, instance, type, state, expected_interval_sec, last_seen_utc,
last_status, last_message, metrics_json, group_key, os, created_utc, updated_utc
) VALUES (
:source, :instance, :type, :state, :interval, :now,
:last_status, :message, :metrics, :group_key, :os, :now, :now
:source, :instance, :type, :state, :interval, NOW(),
:last_status, :message, :metrics, :group_key, :os, NOW(), NOW()
)
ON DUPLICATE KEY UPDATE
state = VALUES(state),
@@ -68,7 +68,6 @@ class MonitorRepo
':type' => $type,
':state' => $state,
':interval' => $intervalSec,
':now' => $nowUtc,
':last_status' => $status,
':message' => $message,
':metrics' => $metricsJson,
+17 -8
View File
@@ -13,25 +13,28 @@ class TokenManager
$this->db = $db;
}
public function createToken(string $source, string $name, string $notes = ''): array
public function createToken(string $source, ?string $name = null, string $notes = ''): array
{
$tokenId = 'tok_' . bin2hex(random_bytes(8));
$rawToken = 'wd_' . bin2hex(random_bytes(24));
$rawToken = 'wd_live_' . bin2hex(random_bytes(18));
$tokenHash = hash('sha256', $rawToken);
$tokenName = !empty($name) ? $name : ("Token for " . ($source ?: 'General'));
$stmt = $this->db->prepare('
INSERT INTO watchdog_agent_tokens (
token_id, token_hash, name, monitor_source, created_at_utc
token_id, token_hash, raw_token, name, monitor_source, created_at_utc
) VALUES (
:id, :hash, :name, :source, NOW()
:id, :hash, :raw, :name, :source, NOW()
)
');
$stmt->execute([
':id' => $tokenId,
':hash' => $tokenHash,
':name' => $name,
':source' => $source,
':raw' => $rawToken,
':name' => $tokenName,
':source' => !empty($source) ? $source : null,
]);
return [
@@ -43,8 +46,8 @@ class TokenManager
public function validateToken(string $rawToken, string $targetSource): bool
{
$hash = hash('sha256', $rawToken);
$stmt = $this->db->prepare('SELECT * FROM watchdog_agent_tokens WHERE token_hash = :hash AND revoked = 0');
$stmt->execute([':hash' => $hash]);
$stmt = $this->db->prepare('SELECT * FROM watchdog_agent_tokens WHERE (token_hash = :hash OR raw_token = :raw) AND revoked = 0');
$stmt->execute([':hash' => $hash, ':raw' => $rawToken]);
$row = $stmt->fetch();
if (!$row) {
@@ -60,4 +63,10 @@ class TokenManager
return true;
}
public function getAllTokens(): array
{
$stmt = $this->db->query('SELECT * FROM watchdog_agent_tokens ORDER BY created_at_utc DESC');
return $stmt->fetchAll() ?: [];
}
}