feat(git): Hinweis im Account-Panel, Startlog, Fehlersuche und Betriebs-Compose (#30)
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (pull_request) Canceled after 0s
CI / Storage (mongo) (pull_request) Canceled after 0s
CI / Storage (postgres) (pull_request) Canceled after 0s

- Panel zeigt bei 503/G10 und 403/G07 einen Hinweis statt sich auszublenden; ohne Login unsichtbar
- Startlog: Info-Zeile bei aktivem Backend (kid, Allowlist), ohne Secrets
- docs/git: Abschnitt Fehlersuche / nachträglich aktivieren
- docs/deploy: compose.yaml-Vorlage für das veröffentlichte Image, Verlinkung aus README/FORK/auth/storage
- Dev-Compose reicht HB_ASSET_* durch

Refs #30

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dev-bot BotandClaude Sonnet 5.5 committed 2026-11-26 11:04:24 +00:00
1 parent 3b83125771
commit f96dec267b
17 files changed
+439 -181

No files matched your search

+5
View File
@@ -74,3 +74,8 @@ HB_OIDC_CLIENT_SECRET=dev-only-client-secret
# HB_GIT_MAX_CONCURRENCY=2 # HB_GIT_MAX_CONCURRENCY=2
# HB_GIT_COMMITTER_NAME=Homebrewery # HB_GIT_COMMITTER_NAME=Homebrewery
# HB_GIT_COMMITTER_EMAIL= # HB_GIT_COMMITTER_EMAIL=
# Bild-Upload (ADR 0004): nur mit aktivem Git-Backend, Standard an
# HB_ASSETS_ENABLED=true
# HB_ASSET_MAX_BYTES=5242880
# HB_ASSET_MAX_BYTES_PER_BREW=52428800
# HB_ASSET_TYPES=png,jpeg,gif,webp
+2
View File
@@ -105,6 +105,8 @@ version, run `dockerhub-sync.yml` with e.g. `v1.0.0`.
`buildcache` is the BuildKit layer cache, not a runnable image. `buildcache` is the BuildKit layer cache, not a runnable image.
Running the published image (Compose template with PostgreSQL 18, OIDC, Git backend and image upload, German): [docs/deploy/README.md](docs/deploy/README.md).
Runner and repository settings (repository → Settings → Actions): Runner and repository settings (repository → Settings → Actions):
- **Runner:** jobs use `runs-on: ubuntu-latest` (public runner, as in the DnD Character Manager). - **Runner:** jobs use `runs-on: ubuntu-latest` (public runner, as in the DnD Character Manager).
+178 -174
View File
@@ -1,174 +1,178 @@
# The Homebrewery # The Homebrewery
[![Homebrewery](https://circleci.com/gh/naturalcrit/homebrewery/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/naturalcrit/homebrewery?branch=master) [![Homebrewery](https://circleci.com/gh/naturalcrit/homebrewery/tree/master.svg?style=svg)](https://app.circleci.com/pipelines/github/naturalcrit/homebrewery?branch=master)
The Homebrewery is a tool for making authentic looking [D&D content][dnd-content-url] The Homebrewery is a tool for making authentic looking [D&D content][dnd-content-url]
using [Markdown][markdown-url]. It is distributed under the terms of the [MIT License](./license). using [Markdown][markdown-url]. It is distributed under the terms of the [MIT License](./license).
[dnd-content-url]: https://dnd.wizards.com/products/tabletop-games/rpg-products/rpg_playershandbook [dnd-content-url]: https://dnd.wizards.com/products/tabletop-games/rpg-products/rpg_playershandbook
[markdown-url]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet [markdown-url]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
## Quick Start ## Quick Start
The easiest way to get started using The Homebrewery is to use it The easiest way to get started using The Homebrewery is to use it
[on our website][homebrewery-url]. The code is open source, so feel free to [on our website][homebrewery-url]. The code is open source, so feel free to
clone it and tinker with it. If you want to make changes to the code, you can run clone it and tinker with it. If you want to make changes to the code, you can run
your own local version for testing by following the installation instructions your own local version for testing by following the installation instructions
below. below.
[homebrewery-url]: https://homebrewery.naturalcrit.com [homebrewery-url]: https://homebrewery.naturalcrit.com
### Installation ### Installation
First, install three programs that The Homebrewery requires to run and retrieve First, install three programs that The Homebrewery requires to run and retrieve
updates: updates:
1. install [node](https://nodejs.org/en/), version v16 or higher. 1. install [node](https://nodejs.org/en/), version v16 or higher.
1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version) 1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version)
For the easiest installation, follow these steps: For the easiest installation, follow these steps:
1. In the installer, uncheck the option to run as a service. 1. In the installer, uncheck the option to run as a service.
1. You can install MongoDB Compass if you want a GUI to view your database documents. 1. You can install MongoDB Compass if you want a GUI to view your database documents.
1. If you install any version over 6.0, you will have to install [MongoDB Shell](https://www.mongodb.com/try/download/shell). 1. If you install any version over 6.0, you will have to install [MongoDB Shell](https://www.mongodb.com/try/download/shell).
1. Go to the C:\ drive and create a folder called "data". 1. Go to the C:\ drive and create a folder called "data".
1. Inside the "data" folder, create a new folder called "db". 1. Inside the "data" folder, create a new folder called "db".
1. Open a command prompt or other terminal and navigate to your MongoDB install folder (C:\Program Files\Mongo\Server\6.0\bin). 1. Open a command prompt or other terminal and navigate to your MongoDB install folder (C:\Program Files\Mongo\Server\6.0\bin).
1. In the command prompt, run "mongod", which will start up your local database server. 1. In the command prompt, run "mongod", which will start up your local database server.
1. While MongoD is running, open a second command prompt and navigate to the MongoDB install folder. 1. While MongoD is running, open a second command prompt and navigate to the MongoDB install folder.
1. Search in Windows for "Advanced system settings" and open it. 1. Search in Windows for "Advanced system settings" and open it.
1. Click "Environment variables", find the "path" variable, and double-click to open it. 1. Click "Environment variables", find the "path" variable, and double-click to open it.
1. Click "New" and paste in the path to the MongoDB "bin" folder. 1. Click "New" and paste in the path to the MongoDB "bin" folder.
1. Click "OK" three times to close all the windows. 1. Click "OK" three times to close all the windows.
1. In the second command prompt, run "mongo", which allows you to edit the database. 1. In the second command prompt, run "mongo", which allows you to edit the database.
1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`. 1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`.
1. Type `db.brews.insertOne({"title":"test"})` to create a blank document. You should see `{ 1. Type `db.brews.insertOne({"title":"test"})` to create a blank document. You should see `{
acknowledged: true, acknowledged: true,
insertedId: ObjectId("63c2fce9e5ac5a94fe2410cf") insertedId: ObjectId("63c2fce9e5ac5a94fe2410cf")
}` }`
1. install [git](https://git-scm.com/downloads) (select the option that allows Git to run from the command prompt). 1. install [git](https://git-scm.com/downloads) (select the option that allows Git to run from the command prompt).
Checkout the repo ([documentation][github-clone-repo-docs-url]): Checkout the repo ([documentation][github-clone-repo-docs-url]):
``` ```
git clone https://github.com/naturalcrit/homebrewery.git git clone https://github.com/naturalcrit/homebrewery.git
``` ```
[github-clone-repo-docs-url]: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository [github-clone-repo-docs-url]: https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository
Second, you will need to add the environment variable `NODE_ENV=local` to allow Second, you will need to add the environment variable `NODE_ENV=local` to allow
the project to run locally. the project to run locally.
You can set this **temporarily** (until you close the terminal) in your shell of choice with admin privileges: You can set this **temporarily** (until you close the terminal) in your shell of choice with admin privileges:
* Windows Powershell: `$env:NODE_ENV="local"` * Windows Powershell: `$env:NODE_ENV="local"`
* Windows CMD: `set NODE_ENV=local` * Windows CMD: `set NODE_ENV=local`
* Linux / macOS: `export NODE_ENV=local` * Linux / macOS: `export NODE_ENV=local`
If you want to add this variable **permanently** the steps are as follows: If you want to add this variable **permanently** the steps are as follows:
1. Search in Windows for "Advanced system settings" and open it. 1. Search in Windows for "Advanced system settings" and open it.
1. Click "Environment variables". 1. Click "Environment variables".
1. In System Variables, click "New" 1. In System Variables, click "New"
1. Click "New" and write `NODE_ENV` as a name and `local` as the value. 1. Click "New" and write `NODE_ENV` as a name and `local` as the value.
1. Click "OK" three times to close all the windows. 1. Click "OK" three times to close all the windows.
This can be undone at any time if needed. This can be undone at any time if needed.
Third, you will need to install the Node dependencies, compile the app, and run Third, you will need to install the Node dependencies, compile the app, and run
it using the two commands: it using the two commands:
1. `npm install` 1. `npm install`
1. `npm start` 1. `npm start`
When the Homebrewery server is started for the first time, it will modify the database to create the indexes required for better Homebrewery performance. This may take a few moments to complete for each index, dependent on how much content is in your local database - a brand new, empty database should be done in seconds. When the Homebrewery server is started for the first time, it will modify the database to create the indexes required for better Homebrewery performance. This may take a few moments to complete for each index, dependent on how much content is in your local database - a brand new, empty database should be done in seconds.
On completion, you should be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use The Homebrewery offline. On completion, you should be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use The Homebrewery offline.
If you had any issue at all, here are some links that may be useful: If you had any issue at all, here are some links that may be useful:
- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, useful for beginners - [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, useful for beginners
- [Mongo community forums](https://www.mongodb.com/community/forums/) - [Mongo community forums](https://www.mongodb.com/community/forums/)
- Useful Stack Overflow links for your most probable errors: [1](https://stackoverflow.com/questions/44962540/mongod-and-mongo-commands-not-working-on-windows-10), [2](https://stackoverflow.com/questions/15053893/mongo-command-not-recognized-when-trying-to-connect-to-a-mongodb-server/41507803#41507803), [3](https://stackoverflow.com/questions/51224959/mongo-is-not-recognized-as-an-internal-or-external-command-operable-program-o) - Useful Stack Overflow links for your most probable errors: [1](https://stackoverflow.com/questions/44962540/mongod-and-mongo-commands-not-working-on-windows-10), [2](https://stackoverflow.com/questions/15053893/mongo-command-not-recognized-when-trying-to-connect-to-a-mongodb-server/41507803#41507803), [3](https://stackoverflow.com/questions/51224959/mongo-is-not-recognized-as-an-internal-or-external-command-operable-program-o)
If you still have problems, post in [Our Subreddit](https://www.reddit.com/r/homebrewery/) and we will help you. If you still have problems, post in [Our Subreddit](https://www.reddit.com/r/homebrewery/) and we will help you.
### Running the application via Docker ### Running the application via Docker
Please see the docs here: [README.DOCKER.md](./README.DOCKER.md) Please see the docs here: [README.DOCKER.md](./README.DOCKER.md)
### Lokal starten / Selbst hosten (Fork homebrewery-oidc) ### Lokal starten / Selbst hosten (Fork homebrewery-oidc)
```bash ```bash
cp .env.example .env # optional, alle Werte haben Entwicklungs-Defaults cp .env.example .env # optional, alle Werte haben Entwicklungs-Defaults
docker compose up --build # App + MongoDB -> http://localhost:8000 docker compose up --build # App + MongoDB -> http://localhost:8000
``` ```
`docker-compose.override.yml` (wird automatisch geladen) und `docker/` enthalten die Fork-Erweiterungen; `docker-compose.yml` bleibt Upstream-identisch. `docker-compose.override.yml` (wird automatisch geladen) und `docker/` enthalten die Fork-Erweiterungen; `docker-compose.yml` bleibt Upstream-identisch.
| Profil | Start | Ergebnis | | Profil | Start | Ergebnis |
|---|---|---| |---|---|---|
| `postgres` | `docker compose --profile postgres up -d postgres` | PostgreSQL 18 auf `127.0.0.1:5432` (ab M2) | | `postgres` | `docker compose --profile postgres up -d postgres` | PostgreSQL 18 auf `127.0.0.1:5432` (ab M2) |
| `keycloak` | `docker compose --profile keycloak up -d` | Keycloak :8080, Realm `homebrewery`, Client `homebrewery`/`dev-only-client-secret`, Nutzer `testuser`/`testuser-dev`, Admin `admin`/`admin-dev`. Discovery: `http://keycloak.localhost:8080/realms/homebrewery/.well-known/openid-configuration` (Start dauert 1–2 Min.) | | `keycloak` | `docker compose --profile keycloak up -d` | Keycloak :8080, Realm `homebrewery`, Client `homebrewery`/`dev-only-client-secret`, Nutzer `testuser`/`testuser-dev`, Admin `admin`/`admin-dev`. Discovery: `http://keycloak.localhost:8080/realms/homebrewery/.well-known/openid-configuration` (Start dauert 1–2 Min.) |
| `authentik` | `docker compose --profile authentik up -d` | authentik :9000, Provider/App `homebrewery` per Blueprint, gleicher Client und Nutzer, Admin `akadmin`/`admin-dev`. Discovery: `http://authentik.localhost:9000/application/o/homebrewery/.well-known/openid-configuration` | | `authentik` | `docker compose --profile authentik up -d` | authentik :9000, Provider/App `homebrewery` per Blueprint, gleicher Client und Nutzer, Admin `akadmin`/`admin-dev`. Discovery: `http://authentik.localhost:9000/application/o/homebrewery/.well-known/openid-configuration` |
Hinweise: Die IdPs laufen unter `keycloak.localhost:8080` bzw. `authentik.localhost:9000` (Issuer für Browser und App-Container identisch, Bindung nur an 127.0.0.1; `*.localhost` löst moderne Browser/OS automatisch auf, sonst `127.0.0.1 keycloak.localhost authentik.localhost` in `/etc/hosts`). Ports nur ändern, wenn Redirect-/Issuer-Einstellungen mitgezogen werden. Alle Zugangsdaten sind reine Dev-Werte, für den Betrieb in `.env` ersetzen. MongoDB 5+ benötigt eine CPU mit AVX; auf älteren CPUs/VMs `MONGO_TAG=4.4` setzen. Der authentik-Blueprint wird beim Erststart automatisch angewendet (dauert einige Minuten, bis die Discovery-URL 200 liefert). Hinweise: Die IdPs laufen unter `keycloak.localhost:8080` bzw. `authentik.localhost:9000` (Issuer für Browser und App-Container identisch, Bindung nur an 127.0.0.1; `*.localhost` löst moderne Browser/OS automatisch auf, sonst `127.0.0.1 keycloak.localhost authentik.localhost` in `/etc/hosts`). Ports nur ändern, wenn Redirect-/Issuer-Einstellungen mitgezogen werden. Alle Zugangsdaten sind reine Dev-Werte, für den Betrieb in `.env` ersetzen. MongoDB 5+ benötigt eine CPU mit AVX; auf älteren CPUs/VMs `MONGO_TAG=4.4` setzen. Der authentik-Blueprint wird beim Erststart automatisch angewendet (dauert einige Minuten, bis die Discovery-URL 200 liefert).
#### Login über OIDC (Keycloak, authentik, …) #### Login über OIDC (Keycloak, authentik, …)
Der Fork bringt einen generischen OIDC-Login (Authorization Code + PKCE) mit. Konfiguration nur über Umgebungsvariablen (`HB_OIDC_ISSUER`, `HB_OIDC_CLIENT_ID`, `HB_OIDC_CLIENT_SECRET`, `HB_PUBLIC_URL`, `HB_SESSION_SECRET`, …, Vorlage in `.env.example`). Die bisherigen Logins (`naturalcrit`: Benutzername/Passwort, Google) bleiben Standard und lassen sich über `HB_AUTH_PROVIDERS` abschalten, abgeschaltete Methoden verschwinden aus der UI und ihre Endpunkte sind gesperrt. Einrichtung, Variablen und Kontozuordnung: [docs/auth/README.md](./docs/auth/README.md), [Keycloak](./docs/auth/keycloak.md), [authentik](./docs/auth/authentik.md). Entscheidung: [ADR 0001](./docs/adr/0001-auth-oidc.md). Der Fork bringt einen generischen OIDC-Login (Authorization Code + PKCE) mit. Konfiguration nur über Umgebungsvariablen (`HB_OIDC_ISSUER`, `HB_OIDC_CLIENT_ID`, `HB_OIDC_CLIENT_SECRET`, `HB_PUBLIC_URL`, `HB_SESSION_SECRET`, …, Vorlage in `.env.example`). Die bisherigen Logins (`naturalcrit`: Benutzername/Passwort, Google) bleiben Standard und lassen sich über `HB_AUTH_PROVIDERS` abschalten, abgeschaltete Methoden verschwinden aus der UI und ihre Endpunkte sind gesperrt. Einrichtung, Variablen und Kontozuordnung: [docs/auth/README.md](./docs/auth/README.md), [Keycloak](./docs/auth/keycloak.md), [authentik](./docs/auth/authentik.md). Entscheidung: [ADR 0001](./docs/adr/0001-auth-oidc.md).
#### Brews in Git speichern #### Brews in Git speichern
Angemeldete OIDC-Nutzer können Brews in einem beliebigen Git-Repository speichern (HTTPS + Personal Access Token, providerneutral: Gitea, Forgejo, GitHub, GitLab, …). Speichern erzeugt einen Commit, beim Öffnen wird der Remote-Stand übernommen, Konflikte werden erkannt und angezeigt. Das Feature ist aus, solange `HB_GIT_TOKEN_KEY` fehlt. Einrichtung, Variablen, Sicherheit und Anbieter-Hinweise: [docs/git/README.md](./docs/git/README.md). Entscheidung: [ADR 0003](./docs/adr/0003-git-backend-und-teilen.md). Angemeldete OIDC-Nutzer können Brews in einem beliebigen Git-Repository speichern (HTTPS + Personal Access Token, providerneutral: Gitea, Forgejo, GitHub, GitLab, …). Speichern erzeugt einen Commit, beim Öffnen wird der Remote-Stand übernommen, Konflikte werden erkannt und angezeigt. Das Feature ist aus, solange `HB_GIT_TOKEN_KEY` fehlt. Einrichtung, Variablen, Sicherheit und Anbieter-Hinweise: [docs/git/README.md](./docs/git/README.md). Entscheidung: [ADR 0003](./docs/adr/0003-git-backend-und-teilen.md). Fehlersuche und nachträgliches Aktivieren: [docs/git/README.md](./docs/git/README.md#fehlersuche--nachträglich-aktivieren).
### Running the application on FreeBSD or FreeNAS #### Betrieb mit dem veröffentlichten Image
Please see the docs here: [README.FreeBSD.md](./README.FREEBSD.md) Compose-Vorlage (App + PostgreSQL 18, OIDC, Git, Bild-Upload) ohne Repo-Checkout: [docs/deploy/README.md](./docs/deploy/README.md). Wichtig: Jede `HB_*`-Variable muss im Container ankommen (`environment:`/`env_file:`), und nach Änderungen gilt `docker compose up -d`, nicht `restart`.
### Standalone PHB Stylesheet ### Running the application on FreeBSD or FreeNAS
If you just want the stylesheet that is generated to make pages look like they
are from the Player's Handbook, you will find it in the Please see the docs here: [README.FreeBSD.md](./README.FREEBSD.md)
[phb.standalone.css](./phb.standalone.css) file.
### Standalone PHB Stylesheet
If you are developing locally and would like to generate your own, follow the If you just want the stylesheet that is generated to make pages look like they
above steps and then run `npm run phb`. are from the Player's Handbook, you will find it in the
[phb.standalone.css](./phb.standalone.css) file.
## Issues, Suggestions, and Bugs
If you run into any issues using The Homebrewery or have suggestions for If you are developing locally and would like to generate your own, follow the
improvement, please submit an issue [on GitHub][repo-issues-url]. above steps and then run `npm run phb`.
You can also get help for issues on the subreddit [r/homebrewery][subreddit-url]
## Issues, Suggestions, and Bugs
[repo-issues-url]: https://github.com/naturalcrit/homebrewery/issues If you run into any issues using The Homebrewery or have suggestions for
[subreddit-url]: https://www.reddit.com/r/homebrewery improvement, please submit an issue [on GitHub][repo-issues-url].
You can also get help for issues on the subreddit [r/homebrewery][subreddit-url]
## Changelog
[repo-issues-url]: https://github.com/naturalcrit/homebrewery/issues
You can check out the [changelog](./changelog.md). [subreddit-url]: https://www.reddit.com/r/homebrewery
## License ## Changelog
This project is licensed under the [MIT license](./license), which means you You can check out the [changelog](./changelog.md).
are free to use The Homebrewery in any way that you want, except for claiming
that you made it yourself. ## License
If you wish to sell, or in some way gain profit for, what's created on this site, This project is licensed under the [MIT license](./license), which means you
it's your responsibility to ensure you have the proper licenses/rights for any are free to use The Homebrewery in any way that you want, except for claiming
images or resources used. that you made it yourself.
## Contributing If you wish to sell, or in some way gain profit for, what's created on this site,
it's your responsibility to ensure you have the proper licenses/rights for any
You are welcome to contribute to the development and maintenance of the images or resources used.
project! There are several ways of doing that:
- At the moment, we have a huge backlog of [issues][repo-issues-url] and some ## Contributing
of them are outdated, duplicates, or don't contain any useful info. To help, you can [mark duplicates][github-mark-duplicate-url], try to
reproduce some complex or weird issues, try finding a workaround for a You are welcome to contribute to the development and maintenance of the
reported bug, or just mention our issue managers team to let them know about project! There are several ways of doing that:
outdated issues via `@naturalcrit/issue-managers`. - At the moment, we have a huge backlog of [issues][repo-issues-url] and some
- Our [subreddit][subreddit-url] is constantly growing and there are number of of them are outdated, duplicates, or don't contain any useful info. To help, you can [mark duplicates][github-mark-duplicate-url], try to
bug reports. Any help with sorting them out is very welcome. reproduce some complex or weird issues, try finding a workaround for a
- And of course you can contribute by fixing a bug or implementing a new reported bug, or just mention our issue managers team to let them know about
feature by yourself, we are waiting for your outdated issues via `@naturalcrit/issue-managers`.
[pull requests][github-pr-docs-url]! - Our [subreddit][subreddit-url] is constantly growing and there are number of
bug reports. Any help with sorting them out is very welcome.
Anyway, if you would like to get in touch with the team and discuss/coordinate - And of course you can contribute by fixing a bug or implementing a new
your contribution to the project, please join our [gitter chat][gitter-url]. feature by yourself, we are waiting for your
[pull requests][github-pr-docs-url]!
[github-mark-duplicate-url]: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/about-duplicate-issues-and-pull-requests
[github-pr-docs-url]: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request Anyway, if you would like to get in touch with the team and discuss/coordinate
[gitter-url]: https://gitter.im/naturalcrit/Lobby your contribution to the project, please join our [gitter chat][gitter-url].
[github-mark-duplicate-url]: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/about-duplicate-issues-and-pull-requests
[github-pr-docs-url]: https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
[gitter-url]: https://gitter.im/naturalcrit/Lobby
+14 -3
View File
@@ -1,13 +1,15 @@
import './git.less'; import './git.less';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { gitApi } from './gitApi.js'; import { gitApi } from './gitApi.js';
import { classifyListError } from './panelState.js';
// Verbindungen verwalten (ADR 0003 §7): anlegen, testen, löschen, Brews aus dem Repo importieren. // Verbindungen verwalten (ADR 0003 §7): anlegen, testen, löschen, Brews aus dem Repo importieren.
// Das Token-Feld ist reines Eingabefeld und wird nie vorbefüllt; der Server gibt den Token nie zurück. // Das Token-Feld ist reines Eingabefeld und wird nie vorbefüllt; der Server gibt den Token nie zurück.
const EMPTY = { label: '', repoUrl: '', authUsername: 'git', token: '' }; const EMPTY = { label: '', repoUrl: '', authUsername: 'git', token: '' };
const GitConnectionsPanel = ()=>{ const GitConnectionsPanel = ()=>{
const [state, setState] = useState('loading'); // loading | off | ready const [state, setState] = useState('loading'); // loading | hidden | notice | ready
const [notice, setNotice] = useState('');
const [conns, setConns] = useState([]); const [conns, setConns] = useState([]);
const [form, setForm] = useState(EMPTY); const [form, setForm] = useState(EMPTY);
const [msg, setMsg] = useState({}); // pro Verbindung: { ok, text } const [msg, setMsg] = useState({}); // pro Verbindung: { ok, text }
@@ -15,10 +17,19 @@ const GitConnectionsPanel = ()=>{
const [files, setFiles] = useState({}); // pro Verbindung: { branch, files } const [files, setFiles] = useState({}); // pro Verbindung: { branch, files }
const reload = ()=>gitApi.listConnections().then((list)=>{ setConns(list); setState('ready'); }) const reload = ()=>gitApi.listConnections().then((list)=>{ setConns(list); setState('ready'); })
.catch((err)=>{ if([403, 503].includes(err.status)) setState('off'); else { setFormError(err.message); setState('ready'); } }); .catch((err)=>{
const { state: next, notice: text } = classifyListError(err);
if(next === 'error') { setFormError(err.message); setState('ready'); } else { setNotice(text ?? ''); setState(next); }
});
useEffect(()=>{ reload(); }, []); useEffect(()=>{ reload(); }, []);
if(state !== 'ready') return null; // Git-Backend deaktiviert oder kein OIDC-Konto if(state === 'notice') return (
<div className='dataGroup gitConnections'>
<h3>Git-Verbindungen <i className='fab fa-git-alt'></i></h3>
<p className='notice'>{notice}</p>
</div>
);
if(state !== 'ready') return null; // lädt oder nicht angemeldet
const set = (id, ok, text)=>setMsg((m)=>({ ...m, [id]: { ok, text } })); const set = (id, ok, text)=>setMsg((m)=>({ ...m, [id]: { ok, text } }));
+1
View File
@@ -16,6 +16,7 @@
} }
.error { color : @red; font-weight : 800; } .error { color : @red; font-weight : 800; }
.ok { color : @teal; font-weight : 800; } .ok { color : @teal; font-weight : 800; }
.notice { color : #555555; font-style : italic; }
ul.files { list-style : none; padding : 0; li { margin : 2px 0; } } ul.files { list-style : none; padding : 0; li { margin : 2px 0; } }
} }
+18
View File
@@ -0,0 +1,18 @@
// Zustand des Git-Panels auf der Account-Seite (FLW-258): aus dem Fehler von GET /api/git/connections
// wird entschieden, ob das Panel einen Hinweis zeigt, normal arbeitet oder unsichtbar bleibt.
export const NOTICES = {
disabled : 'Git-Backend auf diesem Server nicht aktiviert – siehe docs/git (Abschnitt „Fehlersuche / nachträglich aktivieren“).',
noOidc : 'Nur mit OIDC-Anmeldung verfügbar.'
};
/**
* @param {{ status?: number, HBErrorCode?: string }} err Fehler aus gitApi.listConnections()
* @returns {{ state: 'notice'|'hidden'|'error', notice?: string }}
* notice = Hinweis anzeigen, hidden = nichts anzeigen (nicht angemeldet), error = Panel mit Fehlermeldung
*/
export const classifyListError = (err)=>{
if(err?.status === 503 && (!err.HBErrorCode || err.HBErrorCode === 'G10')) return { state: 'notice', notice: NOTICES.disabled };
if(err?.status === 403 && (!err.HBErrorCode || err.HBErrorCode === 'G07')) return { state: 'notice', notice: NOTICES.noOidc };
if(err?.status === 401) return { state: 'hidden' };
return { state: 'error' };
};
@@ -69,7 +69,7 @@ const AccountPage = (props)=>{
{renderSaveLocationButton('Homebrewery', 'HOMEBREWERY')} {renderSaveLocationButton('Homebrewery', 'HOMEBREWERY')}
{renderSaveLocationButton('Google Drive', 'GOOGLE-DRIVE', accountDetails.googleId)} {renderSaveLocationButton('Google Drive', 'GOOGLE-DRIVE', accountDetails.googleId)}
</div> </div>
<GitConnectionsPanel /> {accountDetails.username && <GitConnectionsPanel />}
</> </>
); );
}; };
+5
View File
@@ -45,6 +45,11 @@ services:
HB_GIT_MAX_CONCURRENCY: ${HB_GIT_MAX_CONCURRENCY:-} HB_GIT_MAX_CONCURRENCY: ${HB_GIT_MAX_CONCURRENCY:-}
HB_GIT_COMMITTER_NAME: ${HB_GIT_COMMITTER_NAME:-} HB_GIT_COMMITTER_NAME: ${HB_GIT_COMMITTER_NAME:-}
HB_GIT_COMMITTER_EMAIL: ${HB_GIT_COMMITTER_EMAIL:-} HB_GIT_COMMITTER_EMAIL: ${HB_GIT_COMMITTER_EMAIL:-}
# Bild-Upload (ADR 0004, nur mit aktivem Git-Backend)
HB_ASSETS_ENABLED: ${HB_ASSETS_ENABLED:-}
HB_ASSET_MAX_BYTES: ${HB_ASSET_MAX_BYTES:-}
HB_ASSET_MAX_BYTES_PER_BREW: ${HB_ASSET_MAX_BYTES_PER_BREW:-}
HB_ASSET_TYPES: ${HB_ASSET_TYPES:-}
ports: !override ports: !override
- "${APP_PORT:-8000}:8000" - "${APP_PORT:-8000}:8000"
+3
View File
@@ -36,6 +36,9 @@ Details: [keycloak.md](keycloak.md), [authentik.md](authentik.md).
Die App startet nicht, wenn `oidc` aktiv ist und Pflichtwerte fehlen. Die App startet nicht, wenn `oidc` aktiv ist und Pflichtwerte fehlen.
Betrieb mit dem veröffentlichten Image (eigene Compose-Datei): Alle Variablen müssen unter `environment:`/`env_file:` stehen, nach
Änderungen `docker compose up -d` statt `restart`. Vorlage: [docs/deploy/README.md](../deploy/README.md).
## Login-Methoden ein-/ausschalten (`HB_AUTH_PROVIDERS`) ## Login-Methoden ein-/ausschalten (`HB_AUTH_PROVIDERS`)
Der Redirect-URI beim IdP ist `${HB_PUBLIC_URL}/auth/oidc/callback`, der Post-Logout-URI `${HB_PUBLIC_URL}/`. Der Redirect-URI beim IdP ist `${HB_PUBLIC_URL}/auth/oidc/callback`, der Post-Logout-URI `${HB_PUBLIC_URL}/`.
+44
View File
@@ -0,0 +1,44 @@
# Betrieb mit dem veröffentlichten Image
Für den Betrieb ohne Repo-Checkout: [`compose.yaml`](compose.yaml) (App + PostgreSQL 18, OIDC, Git-Backend,
Bild-Upload) und [`env.example`](env.example). Das Dev-Compose im Repo-Root (`docker-compose.yml` +
`docker-compose.override.yml`) baut das Image selbst und ist nur für die Entwicklung gedacht.
## Image
| Registry | Image | Tags |
| --- | --- | --- |
| Gitea | `git.morlana.online/f.weber/homebrewery-oidc` | `main`, `vX.Y.Z`, `latest` (nur Release), `sha-<7>` |
| Docker Hub | `<DOCKER_HUB_USER>/homebrewery-oidc` | nur `vX.Y.Z` und `latest` |
Details zu CI und Tags: [FORK.md](../../FORK.md#ci-and-container-image). Das Image enthält keine Konfiguration oder Secrets.
## Einrichten
```bash
mkdir homebrewery && cd homebrewery
# compose.yaml und env.example aus docs/deploy/ hierher kopieren
cp env.example .env # Werte eintragen
docker compose config -q # prüft Syntax und Pflichtvariablen
docker compose up -d
docker compose logs homebrewery | head
```
Der Redirect-URI beim IdP ist `<HB_PUBLIC_URL>/auth/oidc/callback` ([docs/auth](../auth/README.md)). TLS und Reverse
Proxy (nginx/Traefik vor Port 8000) sind nicht Teil der Vorlage; `HB_PUBLIC_URL` muss die extern erreichbare
`https://`-URL sein. Der App-Container verbindet sich beim Start mit dem IdP (Discovery) und mit PostgreSQL (Version ≥ 18).
## Wichtig: Variablen müssen im Container ankommen
Der Container sieht **nur** Variablen unter `environment:` (oder aus `env_file:`). Ein Eintrag in `.env` allein reicht
nicht, er füllt nur die `${…}`-Platzhalter in der Compose-Datei. Wer eine eigene Compose-Datei schreibt, muss jede
`HB_*`-Variable (insbesondere `HB_GIT_TOKEN_KEY`) dort ausdrücklich durchreichen. Die Vorlage tut das für alle
Variablen aus [docs/auth](../auth/README.md), [docs/git](../git/README.md) und [docs/storage](../storage/README.md).
Nach jeder Änderung `docker compose up -d` ausführen: `docker compose restart` startet denselben Container mit der
alten Umgebung neu und übernimmt Änderungen **nicht**.
## Git-Backend nachträglich einschalten
Jederzeit möglich, kein Erststart nötig: `HB_GIT_TOKEN_KEY` in `.env` setzen, `docker compose up -d`. Prüfung und
Fehlersuche: [docs/git](../git/README.md#fehlersuche--nachträglich-aktivieren).
+70
View File
@@ -0,0 +1,70 @@
# Betriebs-Vorlage: veröffentlichtes Image + PostgreSQL 18, OIDC-Login, Git-Backend, Bild-Upload.
# Siehe docs/deploy/README.md. Start:
# cp env.example .env # Werte eintragen (Secrets nie einchecken)
# docker compose up -d # nach jeder Änderung an .env erneut `up -d` (nicht `restart`)
#
# WICHTIG: Der Container sieht nur Variablen, die unter `environment:` stehen (oder per `env_file:` geladen werden).
# Eine Variable in .env allein reicht NICHT: .env füllt nur die ${…}-Platzhalter in dieser Datei.
services:
homebrewery:
# Gitea-Registry: git.morlana.online/f.weber/homebrewery-oidc:<tag> (main, vX.Y.Z, latest)
# Docker Hub (nur Release-Tags): <DOCKER_HUB_USER>/homebrewery-oidc:vX.Y.Z
image: ${HB_IMAGE:-git.morlana.online/f.weber/homebrewery-oidc:latest}
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
ports:
- "${APP_PORT:-8000}:8000"
environment:
# Storage (docs/storage/)
HB_DB_DRIVER: postgres
HB_POSTGRES_URL: postgres://${POSTGRES_USER:-homebrewery}:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD setzen}@postgres:5432/${POSTGRES_DB:-homebrewery}
# Auth (docs/auth/)
HB_AUTH_PROVIDERS: oidc
HB_PUBLIC_URL: ${HB_PUBLIC_URL:?HB_PUBLIC_URL setzen}
HB_SESSION_SECRET: ${HB_SESSION_SECRET:?HB_SESSION_SECRET setzen (openssl rand -base64 48)}
HB_OIDC_ISSUER: ${HB_OIDC_ISSUER:?HB_OIDC_ISSUER setzen}
HB_OIDC_CLIENT_ID: ${HB_OIDC_CLIENT_ID:?HB_OIDC_CLIENT_ID setzen}
HB_OIDC_CLIENT_SECRET: ${HB_OIDC_CLIENT_SECRET:?HB_OIDC_CLIENT_SECRET setzen}
HB_OIDC_SCOPES: ${HB_OIDC_SCOPES:-}
HB_OIDC_USERNAME_CLAIM: ${HB_OIDC_USERNAME_CLAIM:-}
HB_OIDC_LINK_BY_EMAIL: ${HB_OIDC_LINK_BY_EMAIL:-}
HB_OIDC_END_SESSION: ${HB_OIDC_END_SESSION:-}
HB_OIDC_LABEL: ${HB_OIDC_LABEL:-}
HB_SESSION_TTL: ${HB_SESSION_TTL:-}
# Git-Backend (docs/git/). Leer = deaktiviert. Erzeugen: openssl rand -base64 32
HB_GIT_TOKEN_KEY: ${HB_GIT_TOKEN_KEY:-}
HB_GIT_TOKEN_KEYS_OLD: ${HB_GIT_TOKEN_KEYS_OLD:-}
HB_GIT_ALLOWED_HOSTS: ${HB_GIT_ALLOWED_HOSTS:-}
HB_GIT_ALLOW_PRIVATE: ${HB_GIT_ALLOW_PRIVATE:-}
HB_GIT_ALLOW_HTTP: ${HB_GIT_ALLOW_HTTP:-}
HB_GIT_TIMEOUT_MS: ${HB_GIT_TIMEOUT_MS:-}
HB_GIT_OPEN_TIMEOUT_MS: ${HB_GIT_OPEN_TIMEOUT_MS:-}
HB_GIT_MAX_FILE_BYTES: ${HB_GIT_MAX_FILE_BYTES:-}
HB_GIT_MAX_CONCURRENCY: ${HB_GIT_MAX_CONCURRENCY:-}
HB_GIT_COMMITTER_NAME: ${HB_GIT_COMMITTER_NAME:-}
HB_GIT_COMMITTER_EMAIL: ${HB_GIT_COMMITTER_EMAIL:-}
# Bild-Upload (ADR 0004, nur mit aktivem Git-Backend)
HB_ASSETS_ENABLED: ${HB_ASSETS_ENABLED:-}
HB_ASSET_MAX_BYTES: ${HB_ASSET_MAX_BYTES:-}
HB_ASSET_MAX_BYTES_PER_BREW: ${HB_ASSET_MAX_BYTES_PER_BREW:-}
HB_ASSET_TYPES: ${HB_ASSET_TYPES:-}
postgres:
image: postgres:18
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-homebrewery}
POSTGRES_USER: ${POSTGRES_USER:-homebrewery}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD setzen}
volumes:
- pgdata:/var/lib/postgresql # PostgreSQL 18: Daten liegen unter /var/lib/postgresql/18/…
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 10
volumes:
pgdata:
+15
View File
@@ -0,0 +1,15 @@
# Kopieren nach .env (neben compose.yaml). Keine Secrets einchecken.
# HB_IMAGE=git.morlana.online/f.weber/homebrewery-oidc:v1.0.0
APP_PORT=8000
POSTGRES_PASSWORD=bitte-aendern
HB_PUBLIC_URL=https://brew.example.org
# openssl rand -base64 48
HB_SESSION_SECRET=bitte-aendern-mindestens-32-byte-zufall-0123456789
HB_OIDC_ISSUER=https://auth.example.org/application/o/homebrewery/
HB_OIDC_CLIENT_ID=homebrewery
HB_OIDC_CLIENT_SECRET=bitte-aendern
# Git-Backend: leer = aus. Erzeugen: openssl rand -base64 32 (genau 32 Byte, sonst Startabbruch; Schlüssel sichern!)
HB_GIT_TOKEN_KEY=
HB_GIT_ALLOWED_HOSTS=git.example.org
+31 -2
View File
@@ -11,7 +11,7 @@ Status/Pull ansehen, aber nichts selbst verknüpfen (`403 G07`).
openssl rand -base64 32 # → HB_GIT_TOKEN_KEY openssl rand -base64 32 # → HB_GIT_TOKEN_KEY
``` ```
Ohne `HB_GIT_TOKEN_KEY` ist das Backend deaktiviert (Warnung beim Start, `/api/git/*` antwortet `503 G10`, Ohne `HB_GIT_TOKEN_KEY` ist das Backend deaktiviert (Warnung beim Start, Hinweis im Account-Panel, `/api/git/*` antwortet `503 G10`,
gespeicherte Brews werden wie bisher nur in der DB gespeichert). Den Schlüssel **nicht verlieren**: Ohne ihn gespeicherte Brews werden wie bisher nur in der DB gespeichert). Den Schlüssel **nicht verlieren**: Ohne ihn
sind gespeicherte Tokens unbrauchbar (Nutzer müssen sie neu eintragen). sind gespeicherte Tokens unbrauchbar (Nutzer müssen sie neu eintragen).
@@ -29,7 +29,36 @@ sind gespeicherte Tokens unbrauchbar (Nutzer müssen sie neu eintragen).
| `HB_GIT_MAX_CONCURRENCY` | `2` | gleichzeitige Git-Operationen pro Prozess (weitere warten, max. 20, sonst `503 G05`) | | `HB_GIT_MAX_CONCURRENCY` | `2` | gleichzeitige Git-Operationen pro Prozess (weitere warten, max. 20, sonst `503 G05`) |
| `HB_GIT_COMMITTER_NAME` / `_EMAIL` | `Homebrewery` / `homebrewery@<Host aus HB_PUBLIC_URL>` | Committer; Autor ist der speichernde Nutzer | | `HB_GIT_COMMITTER_NAME` / `_EMAIL` | `Homebrewery` / `homebrewery@<Host aus HB_PUBLIC_URL>` | Committer; Autor ist der speichernde Nutzer |
Das Docker-Image enthält `git` bereits. Außerhalb von Docker muss `git` (≥ 2.30) im `PATH` liegen. Für den Betrieb mit dem veröffentlichten Image siehe [docs/deploy](../deploy/README.md). Das Docker-Image enthält `git` bereits. Außerhalb von Docker muss `git` (≥ 2.30) im `PATH` liegen.
## Fehlersuche / nachträglich aktivieren
Das Backend lässt sich **jederzeit** einschalten, ein Erststart ist nicht nötig: `HB_GIT_TOKEN_KEY` setzen und den
Prozess neu starten. Die Variable wird bei jedem Start gelesen, die Postgres-Migration `0002_git_backend` läuft immer mit.
Mit Docker Compose gilt: Nach einer Änderung der Umgebung `docker compose up -d` ausführen (erstellt den Container neu).
`docker compose restart` startet den alten Container mit der **alten** Umgebung neu. Die Variable muss außerdem unter
`environment:` (oder `env_file:`) des App-Service stehen, siehe [Betrieb mit dem veröffentlichten Image](../deploy/README.md).
Prüfen, in dieser Reihenfolge:
1. **Kommt der Schlüssel im Container an?** `docker compose exec <service> printenv HB_GIT_TOKEN_KEY | wc -c`: `0` oder
Fehler = nicht gesetzt; ein gültiger Schlüssel (32 Byte, base64) hat 45 Zeichen (44 + Zeilenumbruch).
2. **Startlog** (`docker compose logs <service>`): `Git-Backend aktiv (kid=…, Host-Allowlist: ja|nein)` = an;
`Git-Backend deaktiviert: HB_GIT_TOKEN_KEY ist nicht gesetzt` = aus. Der Log enthält nie den Schlüssel.
3. **API**: `curl -i <HB_PUBLIC_URL>/api/git/connections`:
`503` + `G10` = Backend aus (Schritt 1/2), `401` = nicht angemeldet, `403` + `G07` = Sitzung ohne OIDC-Konto,
`200` = alles in Ordnung (für `403`/`200` mit Sitzungs-Cookie des Browsers).
4. **Panel**: liegt ganz unten auf `/account` („Git-Verbindungen“) und erscheint nur für angemeldete **OIDC-Konten**.
Ist das Backend aus, steht dort der Hinweis „Git-Backend auf diesem Server nicht aktiviert“, bei einer
naturalcrit-Sitzung „Nur mit OIDC-Anmeldung verfügbar“. Ohne Anmeldung ist das Panel unsichtbar.
Ein ungültiger Schlüssel (nicht base64 oder ≠ 32 Byte, auch in `HB_GIT_TOKEN_KEYS_OLD`) **bricht den Start ab**
(`HB_GIT_TOKEN_KEY muss 32 Byte (base64) lang sein`); der Container läuft dann in eine Neustart-Schleife, die Ursache steht im Log.
Schlüsselwechsel: neuen Schlüssel als `HB_GIT_TOKEN_KEY` setzen, den bisherigen in `HB_GIT_TOKEN_KEYS_OLD` (kommagetrennt)
aufnehmen, `up -d`. Tokens werden bei der nächsten Nutzung mit dem neuen Schlüssel neu verschlüsselt; der alte Schlüssel
darf erst entfallen, wenn alle Verbindungen genutzt wurden (die `kid` im Format `v1.<kid>.…` identifiziert den Schlüssel).
## Benutzung ## Benutzung
+2
View File
@@ -30,6 +30,8 @@ docker compose --profile postgres up --build homebrewery-pg
Die Service-Namen gehören dazu: Mit `--profile postgres up` ohne Namen startet Compose zusätzlich die Die Service-Namen gehören dazu: Mit `--profile postgres up` ohne Namen startet Compose zusätzlich die
profillosen Services `homebrewery` und `mongodb` (beide auf `APP_PORT`). profillosen Services `homebrewery` und `mongodb` (beide auf `APP_PORT`).
Für den Betrieb mit dem veröffentlichten Image (PostgreSQL 18, ohne Repo-Checkout): [docs/deploy/README.md](../deploy/README.md).
## Repository-Schicht ## Repository-Schicht
`server/storage/` – `getStorage()` liefert `{ brews, notifications, users }` (`gitConnections`, `brewGitLinks`, `server/storage/` – `getStorage()` liefert `{ brews, notifications, users }` (`gitConnections`, `brewGitLinks`,
+2 -1
View File
@@ -1,4 +1,4 @@
import { readGitConfig } from './config.js'; import { readGitConfig, keyId } from './config.js';
import { createGitService } from './brewSync.js'; import { createGitService } from './brewSync.js';
import { createGitRouter } from './routes.js'; import { createGitRouter } from './routes.js';
import { configureGitHooks } from './hooks.js'; import { configureGitHooks } from './hooks.js';
@@ -14,6 +14,7 @@ export { readGitConfig, createGitService, createGitRouter, configureGitHooks };
export const createGitBackend = ({ getStorage, api, splitTextStyleAndMetadata, env = process.env, logger = console })=>{ export const createGitBackend = ({ getStorage, api, splitTextStyleAndMetadata, env = process.env, logger = console })=>{
const cfg = readGitConfig(env); const cfg = readGitConfig(env);
if(!cfg.enabled) logger.warn?.('Git-Backend deaktiviert: HB_GIT_TOKEN_KEY ist nicht gesetzt (openssl rand -base64 32).'); if(!cfg.enabled) logger.warn?.('Git-Backend deaktiviert: HB_GIT_TOKEN_KEY ist nicht gesetzt (openssl rand -base64 32).');
else logger.info?.(`Git-Backend aktiv (kid=${keyId(cfg.key)}, alte Schlüssel: ${cfg.oldKeys.length}, Host-Allowlist: ${cfg.allowedHosts.length ? `ja (${cfg.allowedHosts.length})` : 'nein'}).`);
const service = createGitService({ cfg, getStorage, api, splitTextStyleAndMetadata, logger }); const service = createGitService({ cfg, getStorage, api, splitTextStyleAndMetadata, logger });
configureGitHooks(cfg.enabled ? service : undefined); configureGitHooks(cfg.enabled ? service : undefined);
// Bild-Upload (ADR 0004) hängt vor dem Git-Router, damit POST …/assets die rohen Bilddaten selbst liest // Bild-Upload (ADR 0004) hängt vor dem Git-Router, damit POST …/assets die rohen Bilddaten selbst liest
+20
View File
@@ -0,0 +1,20 @@
import { classifyListError, NOTICES } from '../../client/fork/git/panelState.js';
describe('Git-Panel: Zustand aus dem Listen-Fehler (FLW-258)', ()=>{
test('503 G10: Hinweis „nicht aktiviert“ mit Verweis auf docs/git', ()=>{
const r = classifyListError({ status: 503, HBErrorCode: 'G10' });
expect(r).toEqual({ state: 'notice', notice: NOTICES.disabled });
expect(r.notice).toMatch(/nicht aktiviert.*docs\/git/);
});
test('403 G07: Hinweis „Nur mit OIDC-Anmeldung verfügbar“', ()=>{
expect(classifyListError({ status: 403, HBErrorCode: 'G07' })).toEqual({ state: 'notice', notice: 'Nur mit OIDC-Anmeldung verfügbar.' });
});
test('401 (nicht angemeldet): Panel bleibt unsichtbar', ()=>{
expect(classifyListError({ status: 401, HBErrorCode: '04' })).toEqual({ state: 'hidden' });
});
test('andere Fehler (G05-503, 500, Netzwerk): Panel mit Fehlermeldung, kein Hinweis', ()=>{
expect(classifyListError({ status: 503, HBErrorCode: 'G05' }).state).toBe('error');
expect(classifyListError({ status: 500 }).state).toBe('error');
expect(classifyListError(new Error('offline')).state).toBe('error');
});
});
+28
View File
@@ -0,0 +1,28 @@
import { createGitBackend } from '../../server/fork/git/index.js';
import { configureGitHooks } from '../../server/fork/git/hooks.js';
const KEY = Buffer.alloc(32, 7).toString('base64');
const boot = (env)=>{
const logger = { warn: jest.fn(), info: jest.fn(), error: jest.fn() };
createGitBackend({ getStorage: ()=>({}), api: {}, splitTextStyleAndMetadata: ()=>({}), env, logger });
configureGitHooks(undefined);
return logger;
};
describe('Git-Backend: Startlog (FLW-258)', ()=>{
test('ohne Schlüssel: Warnung, keine Info-Zeile', ()=>{
const l = boot({});
expect(l.warn).toHaveBeenCalledWith(expect.stringMatching(/deaktiviert.*HB_GIT_TOKEN_KEY/));
expect(l.info).not.toHaveBeenCalled();
});
test('mit Schlüssel: Info mit kid und Allowlist, ohne Secrets', ()=>{
const l = boot({ HB_GIT_TOKEN_KEY: KEY, HB_GIT_ALLOWED_HOSTS: 'git.example.org' });
expect(l.warn).not.toHaveBeenCalled();
const line = l.info.mock.calls[0][0];
expect(line).toMatch(/aktiv \(kid=[0-9a-f]{8}.*Host-Allowlist: ja/);
expect(line).not.toContain(KEY);
});
test('ohne Allowlist: „nein“', ()=>{
expect(boot({ HB_GIT_TOKEN_KEY: KEY }).info.mock.calls[0][0]).toMatch(/Host-Allowlist: nein/);
});
});