feat(prometheus_exporter sink): add SAR auth strategy#25412
Conversation
Add Subject Access Review (SAR) authentication strategy to the prometheus_exporter sink. fixes vectordotdev#25409
|
Thank you for your contribution! Before we can merge this PR, please sign our Contributor License Agreement. To sign, copy and post the phrase below as a new comment on this PR.
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
cc @vparfonov |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e8f2bbf67
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Check authorization - SAR takes precedence over basic auth when both token and SAR config present | ||
| let is_authorized = self.check_authorization(&req).await; | ||
|
|
||
| match (is_authorized, req.method(), req.uri().path()) { |
There was a problem hiding this comment.
Short-circuit non-metrics routes before SAR checks
In Handler::handle, authorization is awaited before route matching, so with auth.strategy = "sar" every request (including POST /, health probes, and random 404 paths) triggers TokenReview + SubjectAccessReview calls. This turns invalid-path traffic into Kubernetes API load even though only GET /metrics can succeed, making it easy to amplify load on the API server from outside. Please gate SAR evaluation to the /metrics route (and method) so non-metrics requests return immediately.
Useful? React with 👍 / 👎.
| _ => { | ||
| return Err("Must specify either 'path' or 'resource', not both or neither".into()); | ||
| } |
There was a problem hiding this comment.
Fail fast on invalid SAR one-of path/resource settings
The path/resource exclusivity is enforced only at request time, where invalid combinations return an error from validate_token_with_sar. That means a sink configured with strategy = "sar" but with both fields set (or neither set) still starts, then denies all scrapes at runtime. This should be validated during config/build so misconfiguration is surfaced immediately instead of silently breaking metrics after deployment.
Useful? React with 👍 / 👎.
Add Subject Access Review (SAR) authentication strategy to the prometheus_exporter sink. fixes #25409
Summary
This PR:
Vector configuration
How did you test this PR?
Change Type
Is this a breaking change?
Does this PR include user facing changes?
No
no-changeloglabel to this PR.References
Notes
@vectordotdev/vectorto reach out to us regarding this PR.pre-pushhook, please see this template.make fmtmake check-clippy(if there are failures it's possible some of them can be fixed withmake clippy-fix)make testgit merge origin masterandgit push.Cargo.lock), pleaserun
make build-licensesto regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.