Prepare LaySite 1.4.4 editor templates and MCP settings
This commit is contained in:
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Config\Environment;
|
||||
use App\Content\BlockTemplates;
|
||||
use App\Content\Database;
|
||||
use App\Content\DesignLibrary;
|
||||
use App\Content\McpSettings;
|
||||
use App\Content\PageDraft;
|
||||
use App\Content\PageTemplates;
|
||||
use App\Content\Repository;
|
||||
@@ -28,7 +28,15 @@ final class McpController
|
||||
if ($origin !== null && $origin !== '' && $origin !== rtrim(View::absolute(''), '/')) {
|
||||
return new Response(403, ['Cache-Control' => 'no-store']);
|
||||
}
|
||||
$secret = Environment::get('LAYSITE_MCP_TOKEN');
|
||||
try {
|
||||
$settings = McpSettings::read();
|
||||
} catch (RuntimeException) {
|
||||
return new Response(503, ['Cache-Control' => 'no-store']);
|
||||
}
|
||||
$secret = $settings['token'];
|
||||
if ($settings['enabled'] && $secret === null) {
|
||||
return new Response(503, ['Cache-Control' => 'no-store']);
|
||||
}
|
||||
$header = $request->header('authorization', '');
|
||||
if (!is_string($secret) || strlen($secret) < 32 || !is_string($header) || !hash_equals('Bearer ' . $secret, $header)) {
|
||||
return new Response(401, ['WWW-Authenticate' => 'Bearer realm="LaySite MCP"', 'Cache-Control' => 'no-store']);
|
||||
|
||||
Reference in New Issue
Block a user