mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-22 12:57:58 +00:00
Compare commits
No commits in common. "9e3e30a37ae2f04bafb5abfa1f942bc32dcb6293" and "68abf524192c336ed498e2e6d915f640410c2408" have entirely different histories.
9e3e30a37a
...
68abf52419
7 changed files with 40 additions and 76 deletions
12
agents.md
12
agents.md
|
|
@ -115,15 +115,3 @@ This file is the single source of truth for codebase obstacles, oddities, and th
|
|||
**Obstacle:** Theme switching and persisted localStorage theme state conflicted with the current Firebreak brand pass, especially on the cinematic landing page.
|
||||
**Solution/Workaround:** Force the root document to use the `.dark` token set and remove the theme toggle UI/scripts.
|
||||
**Preference:** Keep semantic dark tokens; only reintroduce theme switching after the dark Firebreak identity is stable.
|
||||
|
||||
### Forgejo repository check accepted empty accounts
|
||||
**Area:** cli/src/utils/forgejo-checks.ts
|
||||
**Obstacle:** `checkRepoAccess` treated any parsed user object as success, even when Forgejo reported zero accessible repositories.
|
||||
**Solution/Workaround:** Require `totalRepos > 0` before returning the existing success result; preserve the existing zero-repository failure.
|
||||
**Preference:** A valid token alone is insufficient for repository-access verification.
|
||||
|
||||
### Forgejo PAT could be sent over remote HTTP
|
||||
**Area:** cli/src/utils/forgejo-checks.ts, cli/src/commands/config/init.ts
|
||||
**Obstacle:** CLI setup and verification accepted remote `http://` Forgejo URLs, allowing the PAT to be sent without transport encryption.
|
||||
**Solution/Workaround:** Centralize Forgejo URL validation, require HTTPS for non-local endpoints, and allow HTTP only for the documented `forgejo` service and loopback hosts. Validate again inside authenticated checks before constructing requests.
|
||||
**Preference:** Reject insecure remote transport instead of adding an acknowledgement flag.
|
||||
|
|
|
|||
|
|
@ -5,9 +5,36 @@ import * as c from "yoctocolors";
|
|||
import * as p from "@clack/prompts";
|
||||
|
||||
import { generateEnvFile, SECRET_ENV_KEYS } from "../../utils/config.js";
|
||||
import { validateForgejoBaseUrl } from "../../utils/forgejo-checks.js";
|
||||
import { CommandConfig } from "../../cli-router.js";
|
||||
|
||||
function validateHttpUrlOrHost(
|
||||
value: string | undefined,
|
||||
label: string,
|
||||
): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
if (!trimmed) return `${label} is required`;
|
||||
|
||||
const hasProtocol = /^[a-z]+:\/\//i.test(trimmed);
|
||||
const isHttp = /^https?:\/\//i.test(trimmed);
|
||||
|
||||
if (hasProtocol && !isHttp) {
|
||||
return `${label} must use http:// or https://`;
|
||||
}
|
||||
|
||||
if (!hasProtocol) {
|
||||
return `${label} must include a scheme — e.g. http://forgejo:3000 or https://git.example.com`;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(trimmed);
|
||||
if (!url.hostname) return `${label} must include a domain or hostname`;
|
||||
} catch {
|
||||
return `${label} must be a valid URL`;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function init(opts: { output?: string }) {
|
||||
p.intro(c.bold("firebreak config init"));
|
||||
p.note(
|
||||
|
|
@ -91,7 +118,7 @@ async function init(opts: { output?: string }) {
|
|||
message:
|
||||
"Forgejo API URL (how Firebreak reaches Forgejo, not your browser URL)?",
|
||||
placeholder: "http://forgejo:3000",
|
||||
validate: (v) => validateForgejoBaseUrl(v),
|
||||
validate: (v) => validateHttpUrlOrHost(v, "Forgejo base URL"),
|
||||
}),
|
||||
forgejoPat: () =>
|
||||
p.password({
|
||||
|
|
@ -151,7 +178,7 @@ async function init(opts: { output?: string }) {
|
|||
].join("\n"),
|
||||
);
|
||||
p.log.success(
|
||||
"Done. Verify Firebreak's connection using 'firebreak config verify'.\nOnce verified, deploy!",
|
||||
"Done. Verify firebreak's connection using the 'verify' command.\nOnce verified, deploy!",
|
||||
);
|
||||
} catch (error) {
|
||||
s.stop();
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ async function runForgejoChecks(
|
|||
|
||||
async function verifyCommand(opts: VerifyOptions): Promise<void> {
|
||||
const isDiagnostic = opts.diagnostic ?? false;
|
||||
p.intro(c.bold("firebreak config verify"));
|
||||
p.intro(c.bold("firebreak verify"));
|
||||
|
||||
const config = loadConfig();
|
||||
if (!config) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
const TIMEOUT = 5000;
|
||||
|
||||
const LOCAL_HTTP_HOSTS = new Set([
|
||||
"forgejo",
|
||||
"localhost",
|
||||
"127.0.0.1",
|
||||
"::1",
|
||||
"[::1]",
|
||||
]);
|
||||
|
||||
export type CheckResult = {
|
||||
name: string;
|
||||
success: boolean;
|
||||
|
|
@ -26,42 +18,6 @@ export function createCheckResult(
|
|||
return result;
|
||||
}
|
||||
|
||||
export function validateForgejoBaseUrl(
|
||||
value: string | undefined,
|
||||
label = "Forgejo base URL",
|
||||
): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
if (!trimmed) return `${label} is required`;
|
||||
|
||||
const hasProtocol = /^[a-z]+:\/\//i.test(trimmed);
|
||||
const isHttp = /^https?:\/\//i.test(trimmed);
|
||||
|
||||
if (hasProtocol && !isHttp) {
|
||||
return `${label} must use http:// or https://`;
|
||||
}
|
||||
|
||||
if (!hasProtocol) {
|
||||
return `${label} must include a scheme — e.g. http://forgejo:3000 or https://git.example.com`;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(trimmed);
|
||||
if (!url.hostname) return `${label} must include a domain or hostname`;
|
||||
|
||||
const isLocalHttp =
|
||||
url.protocol === "http:" &&
|
||||
(LOCAL_HTTP_HOSTS.has(url.hostname) ||
|
||||
url.hostname.endsWith(".localhost"));
|
||||
if (url.protocol === "http:" && !isLocalHttp) {
|
||||
return `${label} must use https:// unless it is a local Forgejo endpoint`;
|
||||
}
|
||||
} catch {
|
||||
return `${label} must be a valid URL`;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function fetchWithTimeout(
|
||||
url: string,
|
||||
init: RequestInit,
|
||||
|
|
@ -91,11 +47,6 @@ function getErrorMessage(error: unknown, context: string): string {
|
|||
export async function checkForgejoReachability(
|
||||
baseUrl: string,
|
||||
): Promise<CheckResult> {
|
||||
const validationError = validateForgejoBaseUrl(baseUrl);
|
||||
if (validationError) {
|
||||
return createCheckResult("Forgejo", false, validationError);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetchWithTimeout(baseUrl, { method: "GET" });
|
||||
if (response.ok) {
|
||||
|
|
@ -119,11 +70,6 @@ export async function checkRepoAccess(
|
|||
baseUrl: string,
|
||||
pat: string,
|
||||
): Promise<CheckResult> {
|
||||
const validationError = validateForgejoBaseUrl(baseUrl);
|
||||
if (validationError) {
|
||||
return createCheckResult("Forgejo", false, validationError);
|
||||
}
|
||||
|
||||
try {
|
||||
const responses = await Promise.all([
|
||||
fetchWithTimeout(`${baseUrl}/api/v1/user`, {
|
||||
|
|
@ -155,7 +101,7 @@ export async function checkRepoAccess(
|
|||
reposResponse.headers.get("x-total-count") ?? "0",
|
||||
);
|
||||
|
||||
if (user && totalRepos > 0) {
|
||||
if (user) {
|
||||
return createCheckResult(
|
||||
"Forgejo",
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ For Dokploy users, deploying Firebreak is similar to deploying any other contain
|
|||
|
||||
Firebreak uses its own Postgres database on the same DB server as Forgejo:
|
||||
|
||||
- Separate databases (e.g., `forgejo` and `firebreak_db`)
|
||||
- Separate databases (e.g., `forgejo` and `firebreak`)
|
||||
- NOT shared tables or schemas
|
||||
- Operators can run both on a small VPS efficiently
|
||||
- Independent backups and migrations
|
||||
|
|
@ -204,7 +204,7 @@ The CLI is the primary way to configure and validate Firebreak against an existi
|
|||
- prompt for the Forgejo base URL, for example `https://git.example.com`
|
||||
- collect the dedicated Forgejo username Firebreak should use for API access, for example `firebreak-bot`
|
||||
- collect a user-created Forgejo PAT for that dedicated Forgejo user
|
||||
- collect Firebreak Postgres connection details, for example `postgresql://firebreak:password@db.example.com:5432/firebreak_db`
|
||||
- collect Firebreak Postgres connection details, for example `postgresql://firebreak:password@db.example.com:5432/firebreak`
|
||||
- generate a grant token secret by default unless the operator pastes one
|
||||
- generate all Firebreak-owned config files needed for deployment in Phase 1
|
||||
- write `.env`
|
||||
|
|
@ -219,7 +219,7 @@ Suggested `init` prompt guidance:
|
|||
- Public viewer URL: "What public URL should viewers use for shared links?" Example: `https://share.example.com`
|
||||
- Private admin URL: "What private URL should operators use for the Firebreak admin UI?" Example: `https://admin.example.com`
|
||||
- Forgejo base URL: "What is the base URL of your existing Forgejo instance?" Example: `https://git.example.com`
|
||||
- Firebreak database URL: "What Postgres connection string should Firebreak use?" Example: `postgresql://firebreak:password@db.example.com:5432/firebreak_db`
|
||||
- Firebreak database URL: "What Postgres connection string should Firebreak use?" Example: `postgresql://firebreak:password@db.example.com:5432/firebreak`
|
||||
- Dedicated Forgejo username: "What Forgejo username should Firebreak use for API access?" Example: `firebreak-bot`
|
||||
- Forgejo PAT: "Paste the Forgejo personal access token for that dedicated Forgejo user" Example: `fgp_...`
|
||||
- Grant token secret: "Paste a grant token secret, or press enter to generate one automatically"
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ Only repo owners can create view links for their repos.
|
|||
- public viewer URL, for example `https://share.example.com`
|
||||
- private admin URL, for example `https://admin.example.com` or `https://firebreak-admin.tailnet.ts.net`
|
||||
- Forgejo base URL, for example `https://git.example.com`
|
||||
- Firebreak Postgres URL, for example `postgresql://firebreak:password@db.example.com:5432/firebreak_db`
|
||||
- Firebreak Postgres URL, for example `postgresql://firebreak:password@db.example.com:5432/firebreak`
|
||||
- Forgejo bot username, for example `firebreak-bot`
|
||||
- Forgejo PAT for that dedicated Forgejo user
|
||||
- grant token secret, with secure auto-generation as the default
|
||||
|
|
@ -164,7 +164,7 @@ For Dokploy users, deploying Firebreak is similar to deploying any other contain
|
|||
Firebreak uses its own Postgres database on the same DB server as Forgejo:
|
||||
|
||||
- separate databases (not shared tables with Forgejo)
|
||||
- recommended: same PostgreSQL instance with `forgejo` and `firebreak_db` databases
|
||||
- recommended: same PostgreSQL instance with `forgejo` and `firebreak` databases
|
||||
- clean schema separation prevents coupling to Forgejo's database schema
|
||||
- independent backups and migrations
|
||||
- operators can run both databases on a small VPS efficiently
|
||||
|
|
|
|||
3
examples/firebreak.config.example.json
Normal file
3
examples/firebreak.config.example.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"forgejoBaseUrl": "http://forgejo:3000"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue