metrics-plugin: add authorization for `/metrics` endpoint
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- grafana, prometheus, rust
- Bereich
- backend-api-design, observability-sre, security
Rechercherichtung
Beginne beim /metrics-Handler von metrics-plugin und beim normalen CLN-Plugin-Optionsmechanismus. Verfolge, wie Metrikantworten derzeit bereitgestellt werden, und kläre und dokumentiere dann das Verhalten ohne Zugangsdaten, bevor du gültige, fehlende und ungültige Zugangsdaten in automatisierten Tests abdeckst. Erledigt ist die Aufgabe, wenn authentifizierte Scrapes das bestehende Metrikformat beibehalten und fehlgeschlagene Anfragen keine Metrikdaten zurückgeben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
metrics-plugin exposes /metrics endpoint in order for scraping services (e.g. Prometheus or Grafana Alloy) to collect CLN metrics. Currently, /metrics is open - if the port is configured to be open for the whole world, potentially everyone could access it and observe inner channel data that affects the privacy.
Solution
Add an optional authentication layer in front of the /metrics endpoint so a scraper must present a valid credential before any metrics are returned. When no credential is configured, the plugin should either keep current behavior for backwards compatibility or fail closed — that decision is worth calling out explicitly below.
- HTTP authentication on
/metrics. Support at least one of the standard schemes that both Prometheus and Grafana Alloy natively understand on the scrape side:- Bearer token - plugin is configured with a token; requests must send
Authorization: Bearer <token>. Matches Prometheus/Alloy authorization scrape config. - HTTP Basic auth - plugin is configured with a username/password; matches Prometheus/Alloy
basic_auth.
- Bearer token - plugin is configured with a token; requests must send
- Configuration via plugin options. Expose the credential through the normal CLN plugin option mechanism (e.g.
metrics-auth-token/metrics-basic-user+metrics-basic-pass), and support reading the secret from a file or environment variable rather than a plaintext CLI arg, so it doesn't leak into ps/logs. - Constant-time comparison of the presented credential against the configured one to avoid timing side-channels.
- Correct HTTP semantics. Return 401 Unauthorized (with
WWW-AuthenticateforBasic) on missing/invalid credentials; 200 only on success. Never leak metric data in the body of a failed request.
Open decision to resolve in the issue: should an unconfigured endpoint stay open (backwards compatible, log a warning) or fail closed (secure by default, but breaks existing setups on upgrade)? Recommend fail-closed with a clear migration note, or an explicit metrics-auth-disabled=true opt-out.
Acceptance criteria
[] A request to /metrics without valid credentials returns 401 and no metric data in the body.
[] A request to /metrics with valid credentials returns 200 and the expected metrics.
[] The credential (token or basic user/pass) is configurable through plugin options, and can be supplied via file/env var rather than only a plaintext CLI argument.
[] 401 responses include a WWW-Authenticate header when Basic auth is in use.
[] The behavior when no credential is configured is explicitly defined and documented (fail-closed with opt-out, per decision above), and that path is covered by a test.
[] The secret does not appear in process listings (ps) or plugin logs.
[] Automated tests cover: valid credential -> 200, missing credential -> 401, wrong credential -> 401.
[] Existing metric collection/format is unchanged for authenticated scrapes (no regression).
- Vorherrschende Sprache
- Rust
- Sterne
- 3
- Forks
- 1
- Ø Merge
- 3 T. 14 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Blockstream/cln-plugins
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
Alle Issues in Blockstream/cln-plugins
Ähnliche Issues
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaEvtl. vergeben @lijy91 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
libnativeapi/nativeapi#53 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug db/dameng user-priority/P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
t8y2/dbx#15534 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add a proto for SVR v0.2Evtl. vergeben @cvas22 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
in-toto/attestation#631 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
area:mcp enhancement large-monorepo v0.34.1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag