CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 5m28s
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 22m16s
The agent's API had no machine-readable description, so DAST could not seed a scan of it from a spec (#997) and integrators had nothing to generate a client from. - utoipa 6 + utoipa-axum 0.3: `build_router` registers described routes with `routes!`, which takes each route's path, method, parameters and body from the handler's `#[utoipa::path]`, so the two cannot drift. - `GET /api/v1/openapi.json` serves the document (OpenAPI 3.1). It sits under the API prefix, so the customer authentication covers it, and it is one of the paths the DAST spec parser tries and not one the API fuzzer flags as exposed. - A bearer scheme, set on every operation except the public ones: the DAST spec parser reads operation-level `security` only. - Described so far: the six DAST routes, with path and pagination parameters and the add-target body (core types stay opaque, so core needs no schema derive yet). Response bodies are not described yet. - CI gate: a test fails when a plain route call in `routes.rs` is not in `undescribed_routes.txt`, or the file names a route that is gone. The list (101 paths) only shrinks; describing a route deletes its line. - Docs: the description in the API-keys guide. Tests: - unit: the gate; the DAST operations carry bearer security, `{id}` path and `page`/`limit` query parameters and a JSON body; OpenAPI 3.1; the spec path is not a public one; - integration: the running agent serves the document as JSON. Part 1 of #1006. API keys cannot read the document yet: no key scope covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
59 lines
3.2 KiB
Markdown
59 lines
3.2 KiB
Markdown
# API-Schlüssel
|
|
|
|
Automatisierungen (eine CI-Pipeline, ein Werkmeister-Baustein, eigene Skripte)
|
|
melden sich bei der Prüfwerk-API mit einem API-Schlüssel an statt mit einem
|
|
Benutzerkonto. Schlüssel werden im Portal angelegt und widerrufen; jeder
|
|
Schlüssel gehört zu genau einer Organisation und trägt Berechtigungen
|
|
(_Scopes_).
|
|
|
|
```sh
|
|
curl -H "Authorization: Bearer bp_…" https://pruefwerk.breakpilot.com/api/v1/findings
|
|
```
|
|
|
|
## Was ein Schlüssel darf
|
|
|
|
| Scope | Erlaubt |
|
|
|---|---|
|
|
| `pruefwerk:findings.read` | Befunde lesen (`GET /api/v1/findings`, `/findings/variants`, `/findings/{id}`) |
|
|
| `pruefwerk:findings.write` | Status und Feedback von Befunden ändern (`PATCH /findings/{id}/status`, `/findings/bulk-status`, `/findings/{id}/feedback`); schließt das Lesen ein |
|
|
| `pruefwerk:sbom.read` | Stückliste lesen und exportieren (`GET /api/v1/sbom`, `/sbom/filters`, `/sbom/export`, `/sbom/licenses`, `/sbom/quality`, `/sbom/diff`) |
|
|
| `pruefwerk:scans.read` | Prüfläufe lesen (`GET /api/v1/scan-runs`) |
|
|
| `pruefwerk:scans.run` | Eine Prüfung starten (`POST /api/v1/targets/{id}/scan`, `/dast/targets/{id}/scan`) |
|
|
| `pruefwerk:enisa.read` | ENISA-Meldeentwürfe lesen (`GET /api/v1/targets/{id}/enisa`, `/cves/{id}/enisa`) |
|
|
|
|
Alles andere ist mit einem Schlüssel nicht erreichbar, auch mit allen Scopes:
|
|
Prüfobjekte anlegen oder ändern, Zugangsdaten, Einstellungen, Befunde aus
|
|
manuellen Tests. Einen ENISA-Entwurf freigeben oder melden bleibt immer einer
|
|
Person vorbehalten.
|
|
|
|
Ältere Schlüssel ohne Scopes dürfen nur lesen (die vier `read`-Scopes).
|
|
|
|
## Antworten
|
|
|
|
| Status | Bedeutung |
|
|
|---|---|
|
|
| `401 invalid_api_key` | Schlüssel unbekannt, abgelaufen oder widerrufen |
|
|
| `403 scope_missing` | Der Schlüssel hat den nötigen Scope nicht, oder die Route nimmt keine Schlüssel an; `required` nennt den Scope |
|
|
| `402` | Die Organisation ist eingeschränkt: lesen ja, ändern nein |
|
|
| `503` | Prüfwerk kann den Schlüssel gerade nicht prüfen; später erneut versuchen |
|
|
|
|
## Gut zu wissen
|
|
|
|
- **API-Beschreibung:** `GET /api/v1/openapi.json` liefert die Beschreibung
|
|
der API als OpenAPI 3.1, aus dem Code erzeugt. Sie wächst Route für Route;
|
|
noch nicht beschriebene Routen fehlen darin. Sie ist mit der Anmeldung
|
|
einer Person erreichbar, noch nicht mit einem API-Schlüssel.
|
|
- **Nicht für MCP.** Ein LLM-Werkzeug (Claude Code, Cursor, …) meldet sich an
|
|
der MCP-Schnittstelle mit einem eigenen MCP-Token (`mcpt_…`) an, nicht mit
|
|
einem API-Schlüssel. MCP-Tokens legt eine angemeldete Person im Dashboard
|
|
unter **MCP-Tokens** in der Seitenleiste an; siehe [MCP-Schnittstelle](/features/mcp-server#connecting-an-mcp-client).
|
|
|
|
- **Widerruf wirkt nach höchstens 60 Sekunden.** Prüfwerk merkt sich das
|
|
Prüfergebnis eines Schlüssels eine Minute lang.
|
|
- **Nachvollziehbarkeit:** Änderungen mit einem Schlüssel stehen im Verlauf
|
|
und im Audit-Log unter dem Inhaber des Schlüssels bzw. `apikey:<id>`.
|
|
Handelt ein Werkzeug für eine Person, kann es sie im Header `X-BP-Actor`
|
|
nennen; sie wird mitprotokolliert, berechtigt aber nichts.
|
|
- Ein Schlüssel wirkt nur in seiner eigenen Organisation. Angaben zur
|
|
Organisation in Headern, Pfaden oder Anfragedaten werden ignoriert.
|