' . '

Welcome back

' . '

Manage the tinyauth service and its settings. Log in with your tinyauth account.

' . 'Log in with tinyauth' . ''; 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(); } elseif ($action === 'create_oidc_client') { handle_create_oidc_client(); } elseif ($action === 'create_app_acl') { handle_create_app_acl(); } redirect('index.php'); } $cfg = config(); $flashes = take_flashes(); $lastOutput = $_SESSION['last_output'] ?? ''; unset($_SESSION['last_output']); $token = csrf_token(); $userHtml = '' . h($_SESSION['user']) . '' . 'Log out'; page_start('Dashboard', $userHtml); foreach ($flashes as $flash) { echo '
' . h($flash['message']) . '
'; } if ($allowedGroup === '') { echo '
'; echo '

First-time setup

'; 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, then reload.
'; } else { echo '
'; echo ''; echo ''; echo '
'; foreach ($groups as $group) { echo ''; } echo '
'; echo ''; echo '
'; } echo '
'; page_end(); exit; } if (!$authorized) { echo '
'; echo '

Access denied

'; echo '

You are not in the required tinyauth group ' . h($allowedGroup) . '.

'; echo '
'; 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]; } $stateClass = match ($state) { 'active' => 'state-active', 'failed' => 'state-failed', 'inactive' => 'state-inactive', default => 'state-unknown', }; $service = $cfg['service']; echo '
'; echo '

Service ' . h($service) . '

'; echo '' . h($state) . '
'; echo '
'; echo ''; foreach (SERVICE_ACTIONS as $action) { $disabled = $perms[$action] ? '' : ' disabled'; echo ''; } echo '
'; if ($status !== null) { echo '
' . h($status['output']) . '
'; } if ($lastOutput !== '') { echo '
' . h($lastOutput) . '
'; } echo '
'; $envPath = $cfg['env_file']; $envReadable = is_file($envPath) && is_readable($envPath); $envWritable = $envReadable && is_writable($envPath); $dataWritable = is_writable(data_dir()); echo '
'; echo '

Permission checks

'; if (in_array(false, $perms, true)) { echo '

Missing sudo rules. Install sudoers/tinyauth-web.sudoers ' . 'from this repo and check it with visudo -cf.

'; } echo '
'; echo 'Current group: ' . h($allowedGroup) . ''; echo ''; echo '
'; echo '
'; echo '

Quick notes

'; echo '
'; echo '
'; echo '

Config ' . h($envPath) . '

'; if ($envReadable && ($blank = blank_warning()) !== null) { echo '
' . h($blank) . '
'; } if (!$envReadable) { echo '
The env file cannot be read by this user.
'; } else { $vars = env_parse((string) file_get_contents($envPath)); echo '
'; echo ''; echo '
'; echo ''; foreach ($vars as $key => $value) { $name = h($key); $info = key_info($key); echo ''; } echo ''; echo ''; echo '
VariableValueDelete
' . $name . ''; if ($info !== null) { echo '
' . h($info['desc']) . '
'; } echo '
'; if (preg_match(SECRET_PATTERN, $key)) { $hint = $value === '' ? '(not set)' : '(set, leave blank to keep)'; echo ''; } else { echo ''; } echo '
add
'; echo ''; foreach (known_keys() as $entry) { echo ''; } echo ''; echo '
Saving writes a backup first. Restart the service to apply.'; echo '
'; echo '
'; } echo '
'; echo '
'; echo '

New OIDC client

'; echo '

Creates the variables for a client that apps use to log in through tinyauth. ' . 'Leave the secret blank to generate one.

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '

New app ACL

'; echo '

Creates the access rules for an app behind tinyauth (forward auth). ' . 'Fill in what you need; empty fields are skipped.

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo '

Local users

'; echo '

Tinyauth stores local users as username:hash pairs in ' . 'TINYAUTH_AUTH_USERS (comma-separated). This tool does not create passwords, because tinyauth hashes them.

'; echo '
    '; echo '
  1. On the server, run tinyauth user create --interactive and enter the username and password when asked. ' . 'Avoid typing the password on the command line, so it stays out of your shell history.
  2. '; echo '
  3. Copy the printed username:hash line.
  4. '; echo '
  5. Add it to TINYAUTH_AUTH_USERS in the config above. For several users, separate entries with commas. ' . 'To add a user, append to the existing value. Do not replace it.
  6. '; echo '
  7. Save, then restart tinyauth. Hashes are masked in this tool like other secrets.
  8. '; echo '
'; echo '

Key reference (' . count(known_keys()) . ' keys)

'; echo ''; echo '
'; foreach (known_keys() as $entry) { echo ''; } echo '
KeyDescriptionDefault
' . h($entry['key']) . '' . h($entry['desc']) . '' . ($entry['default'] === '' ? 'none' : '' . h($entry['default']) . '') . '
'; page_end(); function permission_row(string $label, bool $ok, ?string $detail = null): string { $class = $ok ? 'check-ok' : 'check-missing'; $mark = $ok ? '✔ ok' : '✘ missing'; $extra = $detail !== null ? '
' . h($detail) . '' : ''; return '
  • ' . h($label) . $extra . '' . $mark . '
  • '; }