CSP fix + install update

This commit is contained in:
Roman 2023-01-17 20:54:58 +01:00
parent a7fa180c64
commit f9ecf795c2
4 changed files with 16 additions and 26 deletions

@ -24,18 +24,6 @@ class CreateDatabase extends DatabaseScript {
->addString("cookie", 26) ->addString("cookie", 26)
->unique("day", "cookie"); ->unique("day", "cookie");
$queries[] = Route::getHandler($sql)->getInsertQuery([
new DocumentRoute("/admin", false, \Core\Documents\Admin::class),
new DocumentRoute("/register", true, \Core\Documents\Account::class, "account/register.twig"),
new DocumentRoute("/confirmEmail", true, \Core\Documents\Account::class, "account/confirm_email.twig"),
new DocumentRoute("/acceptInvite", true, \Core\Documents\Account::class, "account/accept_invite.twig"),
new DocumentRoute("/resetPassword", true, \Core\Documents\Account::class, "account/reset_password.twig"),
new DocumentRoute("/login", true, \Core\Documents\Account::class, "account/login.twig"),
new DocumentRoute("/resendConfirmEmail", true, \Core\Documents\Account::class, "account/resend_confirm_email.twig"),
new DocumentRoute("/debug", true, \Core\Documents\Info::class),
new StaticFileRoute("/", true, "/static/welcome.html"),
]);
$queries[] = $sql->createTable("Settings") $queries[] = $sql->createTable("Settings")
->addString("name", 32) ->addString("name", 32)
->addString("value", 1024, true) ->addString("value", 1024, true)

@ -11,6 +11,6 @@ class Admin extends TemplateDocument {
$this->title = "Administration"; $this->title = "Administration";
$this->searchable = false; $this->searchable = false;
$this->enableCSP(); $this->enableCSP();
$this->addCSPWhitelist("/js/admin-panel/"); $this->addCSPWhitelist("/react/dist/admin-panel/");
} }
} }

@ -244,24 +244,12 @@ namespace Documents\Install {
$success = false; $success = false;
} }
if (function_exists("posix_getuid")) {
$userId = posix_getuid();
if (fileowner(WEBROOT) !== $userId) {
$username = posix_getpwuid($userId)['name'];
$failedRequirements[] = sprintf("<b>%s</b> is not owned by current user: $username ($userId). " .
"Try running <b>chown -R $userId %s</b> or give the required directories write permissions: " .
"<b>Site/Configuration</b>, <b>Site/Cache</b>, <b>Site/Logs</b>, <b>Core/External</b>",
WEBROOT, WEBROOT);
$success = false;
}
}
if (!function_exists("yaml_emit")) { if (!function_exists("yaml_emit")) {
$failedRequirements[] = "<b>YAML</b> extension is not installed."; $failedRequirements[] = "<b>YAML</b> extension is not installed.";
$success = false; $success = false;
} }
$requiredVersion = '8.0'; $requiredVersion = '8.1';
if (version_compare(PHP_VERSION, $requiredVersion, '<')) { if (version_compare(PHP_VERSION, $requiredVersion, '<')) {
$failedRequirements[] = "PHP Version <b>>= $requiredVersion</b> is required. Got: <b>" . PHP_VERSION . "</b>"; $failedRequirements[] = "PHP Version <b>>= $requiredVersion</b> is required. Got: <b>" . PHP_VERSION . "</b>";
$success = false; $success = false;

@ -229,4 +229,18 @@ abstract class Route extends DatabaseEntity {
public function setExact(bool $exact) { public function setExact(bool $exact) {
$this->exact = $exact; $this->exact = $exact;
} }
public static function getPredefinedValues(): array {
return [
new DocumentRoute("/admin", false, \Core\Documents\Admin::class),
new DocumentRoute("/register", true, \Core\Documents\Account::class, "account/register.twig"),
new DocumentRoute("/confirmEmail", true, \Core\Documents\Account::class, "account/confirm_email.twig"),
new DocumentRoute("/acceptInvite", true, \Core\Documents\Account::class, "account/accept_invite.twig"),
new DocumentRoute("/resetPassword", true, \Core\Documents\Account::class, "account/reset_password.twig"),
new DocumentRoute("/login", true, \Core\Documents\Account::class, "account/login.twig"),
new DocumentRoute("/resendConfirmEmail", true, \Core\Documents\Account::class, "account/resend_confirm_email.twig"),
new DocumentRoute("/debug", true, \Core\Documents\Info::class),
new StaticFileRoute("/", true, "/static/welcome.html"),
];
}
} }