Skip to content

docs: add proposal for web basic-auth support - #8577

Open
bicknell-effodio wants to merge 3 commits into
prometheus-operator:mainfrom
bicknell-effodio:proposal/web-basic-auth
Open

bicknell-effodio wants to merge 3 commits into
prometheus-operator:mainfrom
bicknell-effodio:proposal/web-basic-auth

Conversation

@bicknell-effodio

@bicknell-effodio bicknell-effodio commented May 19, 2026 •

Copy link
Copy Markdown

Description

This PR adds a design proposal for exposing Prometheus's basic_auth_users web-config setting through the Prometheus, Alertmanager and ThanosRuler CRDs, per the project's documented proposal process in CONTRIBUTING.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-reloader having no outbound credentials, and the Thanos sidecar losing its connection to Prometheus. The maintainers' guidance on those PRs (reuse the existing BasicAuth type, 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

  • Add BasicAuthUsers []BasicAuth to the existing WebConfigFileFields struct. Reuse the existing BasicAuth type (Secret-backed; no plaintext in the CR).
  • Require bcrypt-hashed passwords from users; do not hash operator-side.
  • Reconcile a stable, documented per-CR Secret (<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).
  • Define interaction precedence with the existing strategic-merge-patch probe workaround (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.
  • Address bcrypt performance concerns by leaning on exporter-toolkit's existing successful-auth cache.
  • Split implementation across four upstream PRs (this one being PR Adjust config generation for Prometheus v1.3.0-beta.0 #1).

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:

  • Proposal follows the structure in Documentation/proposals/template.md.
  • Filename 202605- matches the <YEAR><MONTH>- convention used by existing proposals in Documentation/proposals/accepted/ and Documentation/proposals/implemented/.
  • Reviewed against CONTRIBUTING.md, RELEASE.md, TESTING.md, SECURITY.md, MAINTAINERS.md, governance.md, the PR template, and the relevant Documentation/platform/ and Documentation/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 with strategic-merge-patch.md and the documentation impact on user-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.

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]>
@bicknell-effodio
bicknell-effodio marked this pull request as ready for review May 19, 2026 14:46
@bicknell-effodio
bicknell-effodio requested a review from a team as a code owner May 19, 2026 14:46

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bicknell-effodio

Copy link
Copy Markdown
Author

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]>
@bicknell-effodio

Copy link
Copy Markdown
Author

Thanks for the thorough review. Pushed a revision that adopts the changes.

Highlights:

  • Operator-managed user → user-supplied internal user. Replaced the operator-generated Secret with a new web.internalUser field that the resource owner populates. No more <PrefixedName>-web-auth Secret, no stable-name contract, no operator-generated credentials.
  • Internal user has an optional passwordBcrypt key. Default behavior: 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. Pass-through behavior (when the user supplies passwordBcrypt): operator verifies match and writes the bcrypt verbatim, falling back to default behavior with a Warning event on mismatch. This lets organizations that want to minimize operator-side cryptography opt out, while keeping the default ergonomic.
  • Volume mounts for in-pod callers, not env-from-secret — rotation propagates without pod restarts.
  • Thanos version gate: basic auth requires Thanos ≥ 0.24.0; older → reconcile error.
  • Workarounds section rewritten — dropped the unsupported spec.secrets+additionalArgs bullet, added the reverse-proxy-sidecar pattern (with a reference to Hades32's report in add support for basic auth web config #4652), dropped the "most popular" framing, and trimmed the ingress-nginx EOL discussion to a single soft sentence inside a broader "proxy-based workarounds share a structural limitation" paragraph. Added an explicit acknowledgment that basic auth isn't a complete security solution and that layered defenses (NetworkPolicies, etc.) are encouraged.
  • CEL open question dropped — agreed it can't see Secret values; runtime validation is the answer for content-based checks, with CEL still enforcing the structural rule that basicAuthUsers requires internalUser.
  • Status-condition/metric open question dropped.

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 passwordBcrypt-optional design satisfies the "operator stays out of provisioning" intent. The other 12 threads I marked resolved.

Happy to iterate further on any of these.

@bicknell-effodio

Copy link
Copy Markdown
Author

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.

@bicknell-effodio

Copy link
Copy Markdown
Author

Still interested in moving this forward, and happy to work with people in this ticket or more realtime.

@simonpasquier

Copy link
Copy Markdown
Contributor

Sorry for the delay, I wanted to look into it but didn't have time. I'll try to get back to it ASAP.

@github-actions github-actions Bot added the stale label Sep 2, 2026
coffeegoesincodecomesout added a commit to coffeegoesincodecomesout/prometheus-operator that referenced this pull request Oct 8, 2026
…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]>
coffeegoesincodecomesout added a commit to coffeegoesincodecomesout/prometheus-operator that referenced this pull request Oct 10, 2026
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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add basic auth to prometheus-config-reloader Support basic_auth_users in web configuration for Prometheus and Alertmanager

2 participants