Repository navigation
docs: add proposal for web basic-auth support - #8577
bicknell-effodio wants to merge 3 commits into
Conversation
Add a design proposal for exposing Prometheus's basic_auth_users web-config setting through the Prometheus, Alertmanager and ThanosRuler CRDs. Issue prometheus-operator#4200 has been open since 2021. Two prior community PRs (prometheus-operator#4652, prometheus-operator#4942) attempted the implementation and were closed unfinished after running into the same set of second-order problems: kubelet probes failing under auth, prometheus-config-reloader having no outbound credentials, and the Thanos sidecar losing its connection to Prometheus. The proposal documents an end-to-end design that addresses each of those callers via an operator- managed internal user, plus an action plan that splits the implementation into four reviewable PRs. Motivation has also shifted since the issue was filed: the most common existing workaround, ingress-nginx with basic auth at the perimeter, is both architecturally weak (the workload itself remains open to in-cluster attackers) and now operationally untenable, as Ingress NGINX is being retired by SIG Network in March 2026 with no further security patches. This commit only adds the proposal document. No code changes. Signed-off-by: Leo Bicknell <[email protected]>
Address three failing CI checks on the proposal PR: 1. spell-check: add Bicknell, elif, runtimeinfo, and webconfig to the cspell dictionary (matching the existing pattern for proper nouns and project-internal terms); rewrite "organisations" as "organizations" and "creds" as "credentials" in the proposal text. 2. Check Documentation formatting and links: mdox fmt --soft-wraps reformatted the embedded Go example to use tab indentation instead of spaces, matching gofmt's expectations on the embedded code block. 3. Generate and format: same as (2); the formatter is consistent across both CI jobs. No content change to the proposal itself. Signed-off-by: Leo Bicknell <[email protected]>
simonpasquier
left a comment
There was a problem hiding this comment.
thanks for putting this document together, it really helps!
|
|
||
| Duplicate usernames are rejected at config-generation time (Prometheus accepts the YAML map but silently overrides). | ||
|
|
||
| ### Operator-managed internal user |
There was a problem hiding this comment.
if possible, I'd prefer if the operator stays out of the business of provisioning that username/password.
One alternative would be that alongside the list of usernames/passwords, the resource's owner provides the "internal" username.
There was a problem hiding this comment.
Adopted "resource owner provides the internal user" with a small extension. New web.internalUser field references a Secret with three keys: username, password (plaintext, required for in-pod callers), and passwordBcrypt (optional).
When passwordBcrypt is absent, the operator bcrypts the plaintext at reconcile and caches the result keyed on a hash of the plaintext — re-bcrypts only on rotation, no per-reconcile churn or Secret-write churn. Cache lives in operator process memory; first reconcile after operator restart re-bcrypts once per workload, then steady state.
When passwordBcrypt is present, the operator verifies it matches the plaintext via bcrypt.CompareHashAndPassword (cached on first success). On match, writes the user-supplied bcrypt verbatim and performs no further operations. On mismatch, emits a Warning event, logs, and falls back to bcrypting the plaintext — the system continues functioning rather than failing reconcile.
This collapses the operator-managed-Secret, rotation, collision, and operator-side-bcrypt concerns into a single coherent design while keeping the "operator stays out of provisioning" property you asked for.
|
I appreciate the prompt useful feedback. I will try and have responses and an updated proposal tomorrow. |
Apply the review feedback from prometheus-operator#8577. Design changes: - Drop operator-managed internal user. The operator no longer generates credentials or owns a Secret with a stable name. Replaced with a user-supplied `web.internalUser` field referencing a Secret with three keys: username, password (plaintext), and an optional passwordBcrypt. - When passwordBcrypt is absent, the operator bcrypts the plaintext at reconcile and caches the result keyed on a hash of the plaintext, so reconciles where the plaintext is unchanged reuse the cached bcrypt and produce byte-identical web-config Secrets. - When passwordBcrypt is set, the operator verifies it matches the plaintext and writes it verbatim. On mismatch the operator falls back to default-mode bcrypting with a Warning event; the system stays functional. - In-pod callers (probes, reloader, sidecar) read credentials from a mounted Secret volume so rotation propagates without pod restarts. Reloader uses --reload-basic-auth-password-file rather than an env var. - Add Thanos version gate (>= 0.24.0) for the http-client-file flag. - basicAuthUsers without internalUser is now a reconcile error. Text changes: - Workarounds list rewritten: drop the unsupported spec.secrets bullet, add the reverse-proxy sidecar pattern with a reference to Hades32's comment in prometheus-operator#4652, drop the "most popular" framing for which we have no data. - Rename the "Ingress-level auth is no longer a defensible answer" subsection to "Proxy-based workarounds share a structural limitation". Treat the proxy-in-front pattern generically; trim the ingress-nginx retirement discussion to a single soft sentence with one citation; add an explicit acknowledgment that basic auth is not a complete security solution and layered defenses (NetworkPolicies, TLS) are encouraged. - Validation section expanded with the new internal user rules and the reconcile-time bcrypt format heuristics. CEL enforces only the structural rule (basicAuthUsers requires internalUser); content-based checks are runtime events since CEL cannot read Secret values. - Open questions trimmed to one item (exporter-toolkit prometheus-operator#151 follow-up). Status-condition/metric and CEL-on-Secret-values questions dropped. - Add a new Alternatives entry documenting Secret-as-user-list as considered and rejected for v1, with rationale and forward-compat note. - Take the suggested addition to the operator-side-bcrypt rejection bullet ("exposes the operator to potential security issues which maintainers don't want to deal with") and clarify that the bullet addresses the general case; the internal user's bounded operator-side bcrypt is a different question handled in "Internal user" above. cspell: - Add bcrypting, bcrypts, htpasswd to the dictionary for the new wording. Signed-off-by: Leo Bicknell <[email protected]>
|
Thanks for the thorough review. Pushed a revision that adopts the changes. Highlights:
I've left the L119 thread (operator-managed user → internal user) unresolved because that's the biggest design change and I'd appreciate your validation that the unified Happy to iterate further on any of these. |
|
Gentle nudge to keep this from going stale. I would love to get a plan so that implementation can begin. I'm happy to make any additional tweaks to the plan. If there are still questions or problems I'm happy to address them here or move to a more realtime communications channel (chat, video conference) to keep things moving. |
|
Still interested in moving this forward, and happy to work with people in this ticket or more realtime. |
|
Sorry for the delay, I wanted to look into it but didn't have time. I'll try to get back to it ASAP. |
…r#5836 / PR prometheus-operator#8577 Replace the proposed auth field table with an explicit deferral to the general operator authentication work tracked in prometheus-operator#5836 (PR prometheus-operator#8577). The key integration point — newClientForAlertmanager — is named, and the expected mechanism (spec.web.internalUser) is described so reviewers understand exactly what this proposal is waiting on. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The proposal was 5912 words, roughly 3x implemented/202411-zone-aware-sharding.md (1965) — the longest comparable feature proposal in the repo — and 4x the median. The excess was prose rather than substance: 3099 words of it against zone-aware's 1337, where that proposal carries its weight in YAML and pseudocode instead. Reduce it to 4249 words, following the house style in zone-aware-sharding: - Alternatives log decisions rather than arguing them down. Each of the five keeps its conclusion and its reason; the enumerated rebuttals go. - Drop the Identity Tracking section. Every claim it made was already stated earlier: that the UUID in .status.bindings[].silenceID is the sole identity anchor, that it is written on creation and read on subsequent reconciles, and that identity is deliberately not encoded into comment or createdBy. - Drop the prometheus-operator#8577 status archaeology from Authentication, which would be stale within months, keeping the three commitments and the CA handling. - Reduce the SilenceMatcher justification from four paragraphs to one: the deprecated regex field on v1alpha1.Matcher is the whole reason. - Turn the pitfalls list and the endpoint caveats into bullets. - Remove hedging ("worth flagging", "worth stating precisely") and the paragraph justifying which metrics are not exposed. Every table, code block, condition reason and decision is retained, and no design choice changes. Also reorder the action plan to put the feature gate first, as zone-aware-sharding does, so each later step can merge incrementally without being live for users. This splits the old combined item: the gate is a standalone feature_gates.go entry that nothing reads yet, while the startup pre-flight checks the CRD and the ClusterRole verbs and so has to follow both. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Nigel Smith <[email protected]>
Description
This PR adds a design proposal for exposing Prometheus's
basic_auth_usersweb-config setting through thePrometheus,AlertmanagerandThanosRulerCRDs, per the project's documented proposal process inCONTRIBUTING.md.The proposal is documentation only. No code changes are included; the implementation will be split into separate PRs after maintainer feedback on the design.
Why now
Issue #4200 has been open since 2021. Two prior community PRs (#4652 and #4942) attempted the implementation and were closed unfinished after both ran into the same set of downstream problems: kubelet probes failing under basic auth,
prometheus-config-reloaderhaving no outbound credentials, and the Thanos sidecar losing its connection to Prometheus. The maintainers' guidance on those PRs (reuse the existingBasicAuthtype, no plaintext in the CR, generate an operator-managed user for in-pod callers) shaped the design here.Motivation has also strengthened in the meantime. The most popular existing workaround — ingress-nginx with basic auth at the perimeter — is both structurally weak (it leaves the in-cluster ClusterIP open to lateral attackers) and now operationally untenable: SIG Network announced the retirement of Ingress NGINX in November 2025, with the project retiring in March 2026 and no further security patches afterward.
Summary of the proposal
BasicAuthUsers []BasicAuthto the existingWebConfigFileFieldsstruct. Reuse the existingBasicAuthtype (Secret-backed; no plaintext in the CR).<PrefixedName>-web-auth) containing an operator-managed internal user. Use it for probes (switched to exec when auth is on),prometheus-config-reloader(new--reload-basic-auth-*flags), and the Thanos sidecar (prometheus.http-client-file).Documentation/platform/strategic-merge-patch.md, hardened in fix: #8421 Operator hardcode the Prometheus probe type to HTTPS when https and web.config enabled #8427); user overrides continue to win.The full design, including alternatives considered and open questions for maintainer input, is in the proposal document itself:
Documentation/proposals/202605-web-basic-auth.md.Related issues
Closes: #4200 (after the implementation PRs land)
Will close: #5836 (after PR #2 lands)
Type of change
CHANGE(fix or feature that would cause existing functionality to not work as expected)FEATURE(non-breaking change which adds functionality)BUGFIX(non-breaking change which fixes an issue)ENHANCEMENT(non-breaking change which improves existing functionality)NONE(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Verification
Documentation-only change; no automated test applies. Manual checks performed:
Documentation/proposals/template.md.202605-matches the<YEAR><MONTH>-convention used by existing proposals inDocumentation/proposals/accepted/andDocumentation/proposals/implemented/.CONTRIBUTING.md,RELEASE.md,TESTING.md,SECURITY.md,MAINTAINERS.md,governance.md, the PR template, and the relevantDocumentation/platform/andDocumentation/user-guides/pages to ensure the proposal does not contradict documented policy, procedure, or contracts. Findings are folded into the proposal where applicable (notably the interaction withstrategic-merge-patch.mdand the documentation impact onuser-guides/basic-auth.md).Changelog entry
AI use disclosure
Per the project's AI use policy: this proposal was drafted with the assistance of Claude (Anthropic) for code-base exploration, prior-PR review, and prose drafting. The author has personally reviewed every line of the proposal and can speak to the why/what/how of each section.