Harden web root, secrets and realtime auth

- .htaccess: refuse .git, .env, docker, nodejs, sdlc*, scripts, archives and
  app internals; security headers, HSTS over TLS, optional HTTPS redirect
- uploads served through app/file.php to signed-in users only
- Apache/PHP hardening config for the container (ServerTokens, expose_php)
- least-privilege DB account and APP_SECRET_KEY via docker/php/provision.php;
  SMTP passwords re-encrypted with a random IV (secret_box.php)
- Socket.IO rooms from a PHP-signed token; /emit and cron refuse empty secrets
- escape notification text; CLI guards on build scripts; no fixed demo password
This commit is contained in:
Thanakorn
2026-09-24 14:53:40 +07:00
parent e579dd596c
commit ae98dcdcdd
29 changed files with 525 additions and 42 deletions
+10 -4
View File
@@ -2,14 +2,15 @@
//<><><><><><><><> MAIN CONFIG (docker-generated) <><><><><><><><>//
if(true){
$isTest = "master";
$base_url = "/wms-app/";
$server_url = $base_url."app/";
$include_url = $_SERVER['DOCUMENT_ROOT'].$server_url;
$db_server = "db";
$db_user = "root";
$db_pass = "${DB_ROOT_PASSWORD}";
// Least-privilege account created by the entrypoint (docker/php/entrypoint.sh);
// root is only used there and by setup.php.
$db_user = "${DB_APP_USER}";
$db_pass = "${DB_APP_PASSWORD}";
$db_type = "mysql";
$db_database = "wms";
$db_database2 = "wms2";
@@ -58,7 +59,12 @@ $packages = [
],
];
// unique key — used for SMTP password encryption, keep consistent across deploys
// Key for stored SMTP passwords (assets/utils/secret_box.php). Keep it stable
// across deploys: changing it makes saved SMTP passwords unreadable.
if (!defined('APP_SECRET_KEY')) {
define('APP_SECRET_KEY', '${APP_SECRET_KEY}');
}
// Legacy fixed key: only used to read SMTP passwords saved before APP_SECRET_KEY.
$pinkey = "wms";
$SMTP = [];