Files
docker/remarkable/web/auth.php
Borgal b63131c0c5 Add reMarkable backup system with web UI
- Docker container with rmapi cloud backup, PDF conversion pipeline
- Web UI: file browser, multi-select, delete/move, thumbnail preview
- Sync: backup from reMarkable cloud, rmdoc→PDF conversion via rmc+Inkscape
- Excluded-files mechanism to prevent deleted items from returning after sync

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 23:43:36 +01:00

27 lines
807 B
PHP
Executable File

<?php
declare(strict_types=1);
$user = getenv('RM_USER') ?: 'admin';
$pass = getenv('RM_PASS') ?: '';
if ($pass === '') return; // kein Passwort gesetzt → kein Schutz
// PHP Built-in Server liefert keine PHP_AUTH_* Variablen — Header manuell parsen
$authUser = $_SERVER['PHP_AUTH_USER'] ?? '';
$authPass = $_SERVER['PHP_AUTH_PW'] ?? '';
if ($authUser === '' && isset($_SERVER['HTTP_AUTHORIZATION'])) {
$decoded = base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6));
[$authUser, $authPass] = explode(':', $decoded, 2) + ['', ''];
}
$ok = $authUser === $user
&& hash_equals(hash('sha256', $pass), hash('sha256', $authPass));
if (!$ok) {
header('WWW-Authenticate: Basic realm="reMarkable"');
header('HTTP/1.1 401 Unauthorized');
echo 'Zugriff verweigert.';
exit;
}