Fix: SESSION_SECURE_COOKIE verhindert HTTP-Setup (419-Fehler)
Installer setzt SESSION_SECURE_COOKIE=false initial – damit Setup-Wizard über http://ip erreichbar ist. WizardDomains setzt es auf true nach erfolgreichem SSL. mount()-Redirect ohne exit (sauberer Return). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main
parent
4f3066e225
commit
7d30faa7d7
|
|
@ -84,6 +84,26 @@ class WizardDomains extends Command
|
||||||
|
|
||||||
file_put_contents(self::STATE_DIR . '/done', $helperOk ? '1' : '0');
|
file_put_contents(self::STATE_DIR . '/done', $helperOk ? '1' : '0');
|
||||||
Setting::set('ssl_configured', $helperOk ? '1' : '0');
|
Setting::set('ssl_configured', $helperOk ? '1' : '0');
|
||||||
|
|
||||||
|
if ($helperOk && $ssl) {
|
||||||
|
$this->updateEnv(base_path('.env'), 'SESSION_SECURE_COOKIE', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function updateEnv(string $path, string $key, string $value): void
|
||||||
|
{
|
||||||
|
$content = @file_get_contents($path) ?: '';
|
||||||
|
$pattern = '/^' . preg_quote($key, '/') . '=[^\r\n]*/m';
|
||||||
|
$line = $key . '=' . $value;
|
||||||
|
|
||||||
|
if (preg_match($pattern, $content)) {
|
||||||
|
$content = preg_replace($pattern, $line, $content);
|
||||||
|
} else {
|
||||||
|
$content .= "\n{$line}";
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($path, $content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,10 @@ class Wizard extends Component
|
||||||
|
|
||||||
private const STATE_DIR = '/var/lib/mailwolt/wizard';
|
private const STATE_DIR = '/var/lib/mailwolt/wizard';
|
||||||
|
|
||||||
public function mount(): void
|
public function mount()
|
||||||
{
|
{
|
||||||
if (request()->secure()) {
|
if (request()->secure()) {
|
||||||
redirect()->to('http://' . request()->getHttpHost() . '/setup')->send();
|
return redirect()->to('http://' . request()->getHttpHost() . '/setup');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->instance_name = config('app.name', 'Mailwolt');
|
$this->instance_name = config('app.name', 'Mailwolt');
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ upsert_env CACHE_STORE "redis"
|
||||||
upsert_env CACHE_DRIVER "redis"
|
upsert_env CACHE_DRIVER "redis"
|
||||||
upsert_env CACHE_PREFIX "${APP_USER_PREFIX}_cache:"
|
upsert_env CACHE_PREFIX "${APP_USER_PREFIX}_cache:"
|
||||||
upsert_env SESSION_DRIVER "redis"
|
upsert_env SESSION_DRIVER "redis"
|
||||||
upsert_env SESSION_SECURE_COOKIE "${SECURE}" # DEV=false, PROD=true
|
upsert_env SESSION_SECURE_COOKIE "false" # wird nach SSL-Setup auf true gesetzt
|
||||||
upsert_env SESSION_SAMESITE "lax"
|
upsert_env SESSION_SAMESITE "lax"
|
||||||
upsert_env REDIS_CLIENT "phpredis"
|
upsert_env REDIS_CLIENT "phpredis"
|
||||||
upsert_env REDIS_HOST "127.0.0.1"
|
upsert_env REDIS_HOST "127.0.0.1"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue