Repository navigation
Conversation
There was a problem hiding this comment.
Thanks for your PR!
We shouldn't expose credentials directly in the custom resource for security reasons. One approach would be to have a list of references to secret keys like for other sensitive fields. Lets reuse the existing BasicAuth struct:
type Prometheus struct {
...
BasicAuthUsers []BasicAuth `json:"basicAuthUsers,omitempty"`
...
}
Another point to keep in mind is that the config reloader uses the Prometheus web service so it needs to be configured with valid authn credentials.
|
I see that @fpetkovski commented on the issue that we could reuse the existing basicAuth type which makes sense indeed. |
|
Thanks for your comments! Yes, I realized just now, that also the health check is actually affected by this... |
b704b42 to
f652e73
Compare
|
@simonpasquier OK, so changing to the existing
WDYT? |
|
My instinct would be to generate a user/password for the config reloader and append it to the list provided by the user (if not empty). It sounds better than reusing an existing user/password (cleaner separation). Liveness/readiness probes are another issue indeed... In this case, we could use an exec probe (already the case when Prometheus listens on localhost) and inject the credentials via environment variables. Ideally Prometheus shouldn't require authentication for the |
|
Hi any news concerning this feature ? |
|
Unfortunately, I didn't have time to finish this and solved it by simply running an Nginx sidecar container that only does basic-auth |
how to configur the config reloader with authncredentials |
|
Hey @Hades32, I'm closing this one since you've communicated that you won't be able to continue. Thanks for the effort and feel free to re-open if you feel like continuing in the future :) |
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]>
Description
Extends WebSpec with basic-auth user information to secure the Prometheus API
This fixes #4200
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
xin the box that apply.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.)Changelog entry
Add support for configuring HTTP basic auth. See Prometheus docs for details.
Draft: Open Points