Impressum/Datenschutz für Abrufdienste freigeben
- web/robots.txt als echte Datei: vorher landete /robots.txt im Front Controller und antwortete mit 303 auf /login. Jetzt: Allow für /impressum und /datenschutz, Disallow für den Rest.\n- X-Robots-Tag noindex/nofollow/noarchive nur noch für die App, nicht mehr für die beiden Pflichtseiten.\n- Kein Session-Cookie mehr auf den Rechtsseiten (Header wurden vor dem Session-Start gesetzt).
This commit is contained in:
parent
cf1849a9ce
commit
87ccd36d0a
3 changed files with 15 additions and 4 deletions
|
|
@ -59,12 +59,13 @@ set_exception_handler(static function (Throwable $error): void {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli') {
|
||||||
security_headers();
|
|
||||||
// Öffentliche Rechtsseiten, Health-Check und Cron brauchen keine Session.
|
// Öffentliche Rechtsseiten, Health-Check und Cron brauchen keine Session.
|
||||||
// So wird auf Impressum/Datenschutz kein unnötiges Sitzungs-Cookie gesetzt.
|
// So wird auf Impressum/Datenschutz kein unnötiges Sitzungs-Cookie gesetzt.
|
||||||
$path = current_path();
|
$path = current_path();
|
||||||
|
$legalPublic = legal_is_public_path($path);
|
||||||
|
security_headers($legalPublic);
|
||||||
$sessionFree = ['/health', '/cron/reminders'];
|
$sessionFree = ['/health', '/cron/reminders'];
|
||||||
if (!legal_is_public_path($path) && !in_array($path, $sessionFree, true)) {
|
if (!$legalPublic && !in_array($path, $sessionFree, true)) {
|
||||||
start_session();
|
start_session();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,14 @@ function is_https(): bool
|
||||||
return strtolower((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')) === 'https';
|
return strtolower((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')) === 'https';
|
||||||
}
|
}
|
||||||
|
|
||||||
function security_headers(): void
|
function security_headers(bool $indexable = false): void
|
||||||
{
|
{
|
||||||
header('X-Content-Type-Options: nosniff');
|
header('X-Content-Type-Options: nosniff');
|
||||||
header('X-Frame-Options: DENY');
|
header('X-Frame-Options: DENY');
|
||||||
header('X-Robots-Tag: noindex, nofollow, noarchive');
|
// Impressum/Datenschutz bleiben abrufbar; alles andere ist eine private App.
|
||||||
|
if (!$indexable) {
|
||||||
|
header('X-Robots-Tag: noindex, nofollow, noarchive');
|
||||||
|
}
|
||||||
header('Referrer-Policy: same-origin');
|
header('Referrer-Policy: same-origin');
|
||||||
header('Permissions-Policy: camera=(), microphone=(), geolocation=()');
|
header('Permissions-Policy: camera=(), microphone=(), geolocation=()');
|
||||||
header(
|
header(
|
||||||
|
|
|
||||||
7
web/robots.txt
Normal file
7
web/robots.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Drink it cold – Terminplanung
|
||||||
|
# Die App selbst ist nicht öffentlich; nur die Pflichtseiten dürfen
|
||||||
|
# abgerufen werden (Links, Vorschauen, Suchmaschinen).
|
||||||
|
User-agent: *
|
||||||
|
Allow: /impressum
|
||||||
|
Allow: /datenschutz
|
||||||
|
Disallow: /
|
||||||
Loading…
Add table
Add a link
Reference in a new issue