tinyauth-web
'; page_end(); exit; } $groups = $_SESSION['groups'] ?? []; $allowedGroup = load_settings()['allowed_group'] ?? ''; $authorized = is_authorized($groups); if ($_SERVER['REQUEST_METHOD'] === 'POST') { require_csrf(); $action = (string) ($_POST['action'] ?? ''); if ($allowedGroup === '' && $action === 'setup') { handle_setup($groups); } elseif (!$authorized) { http_response_code(403); exit('Forbidden'); } elseif ($action === 'reset_group') { handle_reset_group(); } elseif (in_array($action, SERVICE_ACTIONS, true)) { handle_service($action); } elseif ($action === 'save_config') { handle_save_config(); } redirect('index.php'); } $cfg = config(); $flashes = take_flashes(); $lastOutput = $_SESSION['last_output'] ?? ''; unset($_SESSION['last_output']); $token = csrf_token(); page_start('tinyauth-web'); echo '' . h($flash['message']) . '
'; } if ($allowedGroup === '') { echo 'Choose the tinyauth group whose members may use this tool.
'; if ($groups === []) { echo 'Your account has no groups in tinyauth. Add yourself to a group first, then reload.
'; } else { echo ''; } echo 'You are not in the required tinyauth group ' . h($allowedGroup) . '.
'; page_end(); exit; } $perms = []; foreach (SERVICE_ACTIONS as $action) { $perms[$action] = service_allowed($action); } $status = $perms['status'] ? service_run('status') : null; $state = 'unknown'; if ($status !== null && preg_match('/Active:\s+(\S+)/', $status['output'], $m)) { $state = $m[1]; } $service = $cfg['service']; echo '' . h($service) . 'State: ' . h($state) . '
'; echo ''; if ($status !== null) { echo '' . h($status['output']) . ''; } if ($lastOutput !== '') { echo '
' . h($lastOutput) . ''; } echo '
| sudo: systemctl ' . h($action) . ' ' . h($service) . ' | ' . permission_mark($perms[$action]) . ' |
| Env file readable (' . h($envPath) . ') | ' . permission_mark($envReadable) . ' |
| Env file writable | ' . permission_mark($envWritable) . ' |
| Data directory writable | ' . permission_mark($dataWritable) . ' |
Missing sudo rules: install sudoers/tinyauth-web.sudoers from this repo (check with visudo -cf).
' . h($envPath) . 'The env file cannot be read by this user.
'; } else { $vars = env_parse((string) file_get_contents($envPath)); echo ''; } echo '