feat(auth): forward SONARQUBE_TOKEN to upstream as Bearer header
The upstream MCP container requires a SonarQube user token in the Authorization header. Without one, every call returns 401. - proxy: read SONARQUBE_TOKEN via sonarqube_token() at session-open time; raise TokenMissingError when unset/blank. upstream_session() attaches the token as "Authorization: Bearer <token>" via streamablehttp_client(headers=...). - cli: fail fast in serve and check with a clear stderr message and exit 1 when the token is missing, before any network attempt. All exception text written to stderr passes through _redact() so an accidentally-leaked token from a third-party exception is replaced with [REDACTED] before display. - The token is never stored on any object, never logged, and the TokenMissingError message contains no token material (it only describes how to generate one in SonarQube). - Tests: header forwarding via mocked streamablehttp_client, missing- token exit code, redaction in CLI error paths, whitespace stripping on the token. Total: 25 tests. - Docs: README/CLAUDE updated with the new env-var, Claude Desktop config snippet, and the security guarantees. CHANGELOG added. Bumps version to 0.2.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,20 @@ diesen weiterleitet. Claude Desktop / Claude App spawnt diesen Prozess via stdio
|
||||
Fehlermeldungen) muss auf `stderr`. `_configure_logging` setzt das fuer das
|
||||
Logging-Modul, `_stderr()` ist der Helper fuer direkte Meldungen.
|
||||
|
||||
### SONARQUBE_TOKEN — Sicherheit
|
||||
|
||||
Der Upstream verlangt einen User-Token im `Authorization`-Header. Wir lesen
|
||||
den Token in `proxy.sonarqube_token()` aus der Env-Var, leiten ihn als
|
||||
`Bearer <token>` an `streamablehttp_client(headers=...)` weiter, und speichern
|
||||
ihn nirgends. Vor jedem stderr-Output mit potenziell ungeprueftem
|
||||
Exception-Text laeuft `cli._redact()`, die den live-Token (falls in der Env)
|
||||
durch `[REDACTED]` ersetzt — defensive Schicht gegen Drittanbieter-Libraries,
|
||||
die in Fehlermeldungen Header einbetten koennten.
|
||||
|
||||
`TokenMissingError` enthaelt **niemals** Token-Material, weil dieser Fall genau
|
||||
heisst: es gibt keinen Token. Die Meldung enthaelt nur die operator-gerichtete
|
||||
Anleitung "My Account -> Security".
|
||||
|
||||
## Lokale Entwicklung
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user