Skip to content

feat(vector): add token authentication to the gRPC source and sink - #25671

Open
stigglor wants to merge 8 commits into
vectordotdev:masterfrom
stigglor:2017-vector-auth-website
Open

stigglor wants to merge 8 commits into
vectordotdev:masterfrom
stigglor:2017-vector-auth-website

Conversation

@stigglor

@stigglor stigglor commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an optional auth setting on both components, supporting the bearer, basic, and custom strategies via a new VectorAuthConfig type that reuses the existing HTTP auth header logic.

The sink sends the credentials on every request, including the health check. The source validates incoming requests with a tonic interceptor using a constant time comparison, and rejects mismatches with an Unauthenticated status. The standard gRPC health service stays open so liveness probes do not need credentials. The token is a normal config value, so it can come from a secrets backend with SECRET[...].

Vector configuration

How did you test this PR?

The bearer-token auth was verified at two levels. Automated: unit tests for the source covering a matching token auth_roundtrip, a missing token, and a wrong token, both rejected with Unauthenticated, plus a constant-time-compare test and an http test confirming VectorAuthConfig produces the right Authorization header for bearer/basic/custom.
End-to-end: a single live vector process wired as demo_logs → vector sink → vector source → console, where matching tokens delivered all 5 events to the console, and a mismatched token produced zero delivered events with the source returning Unauthenticated: "Valid authorization token required.", a failed healthcheck, and the request correctly dropped as non-retriable.

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Closes #2017

Adds an optional auth setting on both components, supporting the bearer,
basic, and custom strategies via a new VectorAuthConfig type that reuses
the existing HTTP auth header logic.

The sink sends the credentials on every request, including the health
check. The source validates incoming requests with a tonic interceptor
using a constant time comparison, and rejects mismatches with an
Unauthenticated status. The standard gRPC health service stays open so
liveness probes do not need credentials. The token is a normal config
value, so it can come from a secrets backend with SECRET[...].

Closes vectordotdev#2017
@stigglor
stigglor requested review from a team as code owners June 24, 2026 05:27
@github-actions github-actions Bot added docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: sources Anything related to Vector's sources domain: sinks Anything related to Vector's sinks domain: external docs Anything related to Vector's external, public documentation and removed docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels Jun 24, 2026
@maycmlee maycmlee added the docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. label Jun 24, 2026
@evazorro evazorro assigned evazorro and unassigned evazorro Jun 29, 2026
@pront pront added the type: feature A value-adding code addition that introduce new functionality. label Jul 13, 2026
@stigglor

stigglor commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@pront 👋 Any timelines on potentially getting this one merged given it's a somewhat smaller change? mTLS auth is unrealistic for larger platforms, and hence being able to use http/2 across our Vector fleet would be a big win.

@pront

pront commented Oct 8, 2026

Copy link
Copy Markdown
Member

@pront 👋 Any timelines on potentially getting this one merged given it's a somewhat smaller change? mTLS auth is unrealistic for larger platforms, and hence being able to use http/2 across our Vector fleet would be a big win.

Hi @stigglor, can you resolve the merge conflicts? I will review shortly.

Comment thread src/http.rs Outdated
/// value, in which case the underlying error is logged by [`Auth::apply_headers_map`].
pub fn authorization_header(&self) -> Option<HeaderValue> {
let mut map = HeaderMap::new();
self.as_auth().apply_headers_map(&mut map);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we ensure custom credentials are redacted throughout this path? Auth::apply_headers_map() logs the complete custom value when header parsing fails. For example, a secret containing a trailing newline gets written to the error log before the source or sink fails to build. This also affects credentials resolved through SECRET[...].

I reproduced this with a dummy credential:

ERROR ... Invalid custom auth header value. value=SSWS dummy-custom-secret

Valid custom headers also have is_sensitive() == false, whereas basic and bearer headers are marked sensitive. Could we use SensitiveString for the custom value, avoid logging its contents on validation errors, and mark the resulting header sensitive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bcf7d04. custom is now a SensitiveString, the header is marked sensitive for all three strategies, and an invalid value now fails the build with an error that names auth.value without logging its contents. Your trailing newline example is covered by authorization_header_error_omits_credentials.

Master moved the vector sink onto ValidatedSink with multiple endpoints, so the auth header now
reaches every endpoint's service and the healthcheck helper. The plaintext warning checks each
endpoint's scheme because TLS now follows the URL rather than the `tls` block, and
`auth_roundtrip` addresses the sink with `http://` for the same reason.
A `custom` auth value that failed header validation was logged in full, and the resulting header
was not marked sensitive, unlike basic and bearer. The value is now a `SensitiveString`, every
strategy's header is marked sensitive, and encoding errors name the option without echoing it.
Reloading with a new credential leaves a window where the source and its sinks disagree, and the
sink treats `Unauthenticated` as final, so the docs no longer present a reload as a safe rotation.
The sink also stops emitting `auth: null` in serialized configs.
@stigglor

Copy link
Copy Markdown
Contributor Author

Hey @pront, sorry for the slow reply on this one, and thanks for taking a look!

I've merged master in and sorted the conflicts. The sink moved over to ValidatedSink with multiple endpoints since I opened this, so the auth header now goes to every endpoint and to the healthchecks too. The plaintext warning also checks each endpoint's scheme now, since TLS follows the URL rather than the tls block.

Good catch on the redaction! The custom value is now a SensitiveString, and the header is built directly rather than going through Auth::apply_headers_map, so nothing gets logged when a value is invalid. The error just names the option (auth.value) without the contents. All three strategies are marked sensitive now as well, which keeps the value out of the HPACK dynamic table on the HTTP/2 connection. I added a test using your trailing newline example.

The shared Auth::Custom on master has the same logging and sensitivity gap for the HTTP components. Happy to put up a separate PR for that if it'd be useful?

Should be ready for another look whenever you get a chance 🙂

Master's Tonic 0.12 upgrade replaced `HyperSvc` with `GrpcTransport`, so the sink now inserts the
auth header there, and `authorization_header` returns an `http_1::HeaderValue` built with headers
0.4.

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

Labels

docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to Vector's sinks domain: sources Anything related to Vector's sources type: feature A value-adding code addition that introduce new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth between Vectors

4 participants