feat: first-run /setup password + PRO-style iptables

compat DNAT/INPUT/FORWARD/MASQUERADE; optional chain mode; auth_store hash; static absolute URLs; install skips env password by default; README.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Андрей Бобырев
2026-05-14 20:52:35 +03:00
parent a579612c9a
commit 43daf188c2
10 changed files with 565 additions and 107 deletions

View File

@@ -6,8 +6,9 @@
<title>{{ ui_title }}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<base href="/">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700&family=JetBrains+Mono:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<link rel="stylesheet" href="/static/styles.css">
</head>
<body>
<div class="shell shell-wide">
@@ -87,7 +88,11 @@
</section>
<footer class="site-footer">
{% if iptables_mode == 'chain' %}
Kaskad Web UI · <a href="https://github.com/andrey271192/kaskad_web_vpn">kaskad_web_vpn</a> · HTTP Basic Auth · DNAT в цепочке <span class="mono">KASKAD_WEB</span> (nat).
{% else %}
Kaskad Web UI · <a href="https://github.com/andrey271192/kaskad_web_vpn">kaskad_web_vpn</a> · HTTP Basic Auth · режим как у Kaskad PRO: DNAT в <span class="mono">PREROUTING</span>, метки <span class="mono">kaskad:PORT:proto</span> в INPUT/FORWARD, <span class="mono">MASQUERADE</span> на исходящем интерфейсе (<span class="mono">KASKAD_IPTABLES_MODE=compat</span>).
{% endif %}
</footer>
</div>
@@ -116,6 +121,6 @@
</div>
</div>
<script src="{{ url_for('static', filename='dashboard.js') }}" defer></script>
<script src="/static/dashboard.js" defer></script>
</body>
</html>

37
templates/setup.html Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Первый вход — пароль</title>
<base href="/">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/static/styles.css">
</head>
<body>
<div class="shell shell-wide">
<div class="card" style="max-width:26rem;margin:2rem auto;">
<h1 class="product-title" style="margin-bottom:0.5rem;">Первый вход</h1>
<p class="muted">Задайте логин и пароль для HTTP Basic Auth (в браузере запросит их при открытии панели).</p>
{% if error %}
<p class="setup-error">{{ error }}</p>
{% endif %}
<form method="post" class="form-grid" style="grid-template-columns:1fr;">
<label>Логин
<input name="username" value="{{ default_user }}" required maxlength="64" autocomplete="username">
</label>
<label>Пароль (мин. 8 символов)
<input name="password" type="password" required minlength="8" autocomplete="new-password">
</label>
<label>Пароль ещё раз
<input name="password2" type="password" required minlength="8" autocomplete="new-password">
</label>
<button type="submit" class="btn" style="justify-self:start;margin-top:0.25rem;">Сохранить и перейти к панели</button>
</form>
<p class="muted" style="margin-top:1rem;font-size:0.78rem;">Данные сохраняются в томе <span class="mono">/var/lib/kaskad/web_auth.json</span>. При указании <span class="mono">ADMIN_PASSWORD</span> или <span class="mono">BASIC_AUTH_PASSWORD</span> в Docker этот шаг пропускается.</p>
</div>
</div>
</body>
</html>