Replace manual .env configuration with a browser-based setup wizard. New users deploy with `docker compose up` and configure Forgejo OAuth credentials through /setup on first visit. Existing users can reconfigure via the same page (auth-gated post-setup). Key changes: Rename (Myst → Firebreak): - Config fields, env vars, session cookie, templates, docker-compose, README all renamed from Myst to Firebreak Setup wizard (/setup): - New AppSettings single-row DB table stores Forgejo config - Auto-generates Fernet encryption key on first setup - SetupRequiredMiddleware redirects all routes to /setup pre-config - Reconfigure mode pre-fills existing values, requires auth - Landing page links to /setup for recovery if OAuth breaks Settings page (/settings): - PAT registration moved out of dashboard into dedicated page - Token card with registration date, delete, and update actions - Dashboard shows CTA linking to settings when no PAT registered Auth updates: - Routes use AppSettings from DB instead of env-based Settings - OAuth callback redirects new users to /settings for PAT setup - Forgejo API errors no longer leak upstream response bodies - Decrypt failures return actionable 503 instead of unhandled 500 Code quality: - Extracted templating.py to eliminate circular import hacks - AppSettings.get_fernet() caches Fernet cipher instance - User.has_pat property replaces scattered None checks - lookup_session promoted to public API - Dead code removed, return type annotations added - PAT input fields use type="password" - CSRF gap documented in agents.md for future addressing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
118 lines
6.1 KiB
HTML
118 lines
6.1 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}{{ "Reconfigure" if reconfiguring else "Setup" }} — Firebreak{% endblock %}
|
|
{% block body_class %}landing-page{% endblock %}
|
|
{% block main_class %}{% endblock %}
|
|
{% block content %}
|
|
<section class="flex min-h-dvh items-center justify-center px-6 py-20">
|
|
<div class="w-full max-w-lg">
|
|
<div class="mb-8 text-center">
|
|
<img src="/static/img/firebreak-brand.svg"
|
|
alt="Firebreak"
|
|
width="240"
|
|
height="268"
|
|
class="mx-auto h-auto w-full max-w-24" />
|
|
<h1 class="mt-6 text-2xl font-semibold text-[#f7f2e8]">
|
|
{{ "Reconfigure" if reconfiguring else "Setup" }}
|
|
</h1>
|
|
{% if reconfiguring %}
|
|
<p class="mt-2 text-sm leading-6 text-[#f7f2e8]/60">
|
|
Update your Forgejo OAuth connection. Make sure the OAuth application
|
|
is registered in your Forgejo instance before continuing.
|
|
</p>
|
|
{% else %}
|
|
<p class="mt-2 text-sm leading-6 text-[#f7f2e8]/60">
|
|
Connect Firebreak to your Forgejo instance. You'll need to
|
|
<a href="https://forgejo.org/docs/latest/user/oauth2-provider/"
|
|
target="_blank"
|
|
rel="noopener"
|
|
class="underline underline-offset-2 text-[#f7f2e8]/80 hover:text-[#f7f2e8]">register an OAuth application</a>
|
|
in Forgejo first.
|
|
</p>
|
|
{% endif %}
|
|
</div>
|
|
{% if not reconfiguring %}
|
|
<div class="mb-8 rounded-lg border border-[#f7f2e8]/10 bg-[#1f2226]/60 px-5 py-4 text-xs leading-5 text-[#f7f2e8]/50">
|
|
<p class="font-medium text-[#f7f2e8]/70 mb-2.5">How to get your OAuth credentials:</p>
|
|
<ol class="list-decimal list-inside space-y-1.5">
|
|
<li>
|
|
In Forgejo, go to <strong class="text-[#f7f2e8]/70">Settings → Applications</strong>
|
|
</li>
|
|
<li>
|
|
Under <strong class="text-[#f7f2e8]/70">Manage OAuth2 Applications</strong>, create a new app
|
|
</li>
|
|
<li>
|
|
Set the redirect URI to
|
|
<br />
|
|
<code class="mt-1 inline-block rounded bg-[#f7f2e8]/8 px-1.5 py-0.5 font-mono text-[10px] text-[#f7f2e8]/60">http://localhost:8000/auth/callback/forgejo</code>
|
|
</li>
|
|
<li>
|
|
Copy the <strong class="text-[#f7f2e8]/70">Client ID</strong> and <strong class="text-[#f7f2e8]/70">Client Secret</strong> into the form below
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
{% endif %}
|
|
<form method="post" action="/setup" class="space-y-5">
|
|
<div>
|
|
<label for="forgejo_base_url"
|
|
class="block text-xs font-semibold uppercase tracking-[0.05em] text-[#f7f2e8]/50 mb-1.5">
|
|
Forgejo Instance URL
|
|
</label>
|
|
<input type="url"
|
|
id="forgejo_base_url"
|
|
name="forgejo_base_url"
|
|
class="block w-full rounded-md border border-[#f7f2e8]/14 bg-[#1f2226] px-3 py-2.5 text-sm text-[#f7f2e8] placeholder:text-[#f7f2e8]/30 focus:border-[#f7f2e8]/30 focus:outline-none focus:ring-2 focus:ring-[#f7f2e8]/10"
|
|
placeholder="https://git.example.com"
|
|
value="{{ forgejo_base_url }}"
|
|
required />
|
|
</div>
|
|
<div>
|
|
<label for="forgejo_oauth_client_id"
|
|
class="block text-xs font-semibold uppercase tracking-[0.05em] text-[#f7f2e8]/50 mb-1.5">
|
|
OAuth Client ID
|
|
</label>
|
|
<input type="text"
|
|
id="forgejo_oauth_client_id"
|
|
name="forgejo_oauth_client_id"
|
|
class="block w-full rounded-md border border-[#f7f2e8]/14 bg-[#1f2226] px-3 py-2.5 font-mono text-sm text-[#f7f2e8] placeholder:text-[#f7f2e8]/30 focus:border-[#f7f2e8]/30 focus:outline-none focus:ring-2 focus:ring-[#f7f2e8]/10"
|
|
placeholder="c8ab3315-537d-44f3-..."
|
|
value="{{ forgejo_oauth_client_id }}"
|
|
required />
|
|
</div>
|
|
<div>
|
|
<label for="forgejo_oauth_client_secret"
|
|
class="block text-xs font-semibold uppercase tracking-[0.05em] text-[#f7f2e8]/50 mb-1.5">
|
|
OAuth Client Secret
|
|
{% if reconfiguring %}
|
|
<span class="ml-1 normal-case tracking-normal font-normal text-[#f7f2e8]/30">(leave blank to keep current)</span>
|
|
{% endif %}
|
|
</label>
|
|
<input type="password"
|
|
id="forgejo_oauth_client_secret"
|
|
name="forgejo_oauth_client_secret"
|
|
class="block w-full rounded-md border border-[#f7f2e8]/14 bg-[#1f2226] px-3 py-2.5 font-mono text-sm text-[#f7f2e8] placeholder:text-[#f7f2e8]/30 focus:border-[#f7f2e8]/30 focus:outline-none focus:ring-2 focus:ring-[#f7f2e8]/10"
|
|
placeholder="gto_wkxxnv4ewa..."
|
|
{{ "" if reconfiguring else "required" }} />
|
|
</div>
|
|
<div>
|
|
<label for="firebreak_public_base_url"
|
|
class="block text-xs font-semibold uppercase tracking-[0.05em] text-[#f7f2e8]/50 mb-1.5">
|
|
Public Base URL
|
|
<span class="ml-1 normal-case tracking-normal font-normal text-[#f7f2e8]/30">(optional)</span>
|
|
</label>
|
|
<input type="url"
|
|
id="firebreak_public_base_url"
|
|
name="firebreak_public_base_url"
|
|
class="block w-full rounded-md border border-[#f7f2e8]/14 bg-[#1f2226] px-3 py-2.5 text-sm text-[#f7f2e8] placeholder:text-[#f7f2e8]/30 focus:border-[#f7f2e8]/30 focus:outline-none focus:ring-2 focus:ring-[#f7f2e8]/10"
|
|
placeholder="https://share.example.com"
|
|
value="{{ firebreak_public_base_url }}" />
|
|
<p class="mt-1.5 text-xs text-[#f7f2e8]/30">
|
|
Your production domain for OAuth redirects. Leave blank on localhost — Firebreak will use <code class="font-mono text-[#f7f2e8]/40">http://localhost:8000</code> automatically.
|
|
</p>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-full mt-2">
|
|
{{ "Save Forgejo settings" if reconfiguring else "Complete Setup" }}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</section>
|
|
{% endblock %}
|