Skip to content

feat(http_server source): allow custom auth to enrich events via metadata writes#25391

Merged
20agbekodo merged 7 commits into
vectordotdev:masterfrom
20agbekodo:josue.agbekodo/http_server_auth_write
May 27, 2026
Merged

feat(http_server source): allow custom auth to enrich events via metadata writes#25391
20agbekodo merged 7 commits into
vectordotdev:masterfrom
20agbekodo:josue.agbekodo/http_server_auth_write

Conversation

@20agbekodo

@20agbekodo 20agbekodo commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR extends the existing custom auth strategy for http_server source to support event enrichment via metadata writes.

Previously, custom auth used set_read_only() which locked both event body (.field) and metadata (%field). This change switches to set_read_only_path(event_root), which keeps the event body read-only while allowing the VRL program to write %field = value. Any metadata written during auth is extracted and injected into every authenticated event.

This avoids introducing a separate custom_enriching strategy — the enrichment capability is folded directly into custom, keeping the UX surface minimal. Existing custom configs that don't write metadata are unaffected (they still return no enrichment).

Behavior

Strategy Event body (.field) Metadata (%field) Enriches events?
basic n/a n/a No
custom read-only writable Yes, if %field written

Example

auth:
  strategy: custom
  source: |
    %tenant_id = .headers."x-tenant-id"
    .headers.authorization == "Bearer secret"

Any authenticated event will have tenant_id injected from the auth VRL program.

Vector configuration

sources:
  my_source:
    type: http_server
    address: 0.0.0.0:8080
    auth:
      strategy: custom
      source: |
        %tenant_id = .headers."x-tenant-id"
        .headers.authorization == "Bearer secret"

How did you test this PR?

  • Unit tests in src/common/http/server_auth.rs covering:
    • Backward compat: existing custom scripts without metadata writes still return Ok(None) (no enrichment, no behavior change)
    • Metadata writes via %field = value are captured and returned as enrichment
    • Attempting to write event body fields (.field) still fails at compile time
  • make check-clippy passes

Change Type

  • New feature

Is this a breaking change?

  • No

The existing custom strategy gains new capability (metadata writes allowed), but all previously valid custom programs continue to work identically.

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.

References

@github-actions github-actions Bot added the domain: sources Anything related to the Vector's sources label May 7, 2026
@20agbekodo 20agbekodo changed the title feat(http_server source): add custom_enriching auth type feat(http_server source): allow custom auth to enrich events via metadata writes May 18, 2026
@20agbekodo 20agbekodo force-pushed the josue.agbekodo/http_server_auth_write branch from e445183 to 9c2bde0 Compare May 18, 2026 20:08
@20agbekodo

Copy link
Copy Markdown
Contributor Author

@codex

@20agbekodo 20agbekodo marked this pull request as ready for review May 18, 2026 20:13
@20agbekodo 20agbekodo requested a review from a team as a code owner May 18, 2026 20:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c2bde0621

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/util/http/prelude.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 137f3b8dc8

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/http/server_auth.rs
@20agbekodo 20agbekodo requested a review from a team as a code owner May 19, 2026 14:27
@github-actions github-actions Bot added domain: external docs Anything related to Vector's external, public documentation docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels May 19, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6fdade80c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9b41bd3a0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs
@20agbekodo

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9b41bd3a0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs Outdated
…pported sources

Sources that implement HttpSource but don't override inject_auth_enrichment
(heroku_logs, prometheus pushgateway/remote_write) would silently drop any
%field metadata written in a custom auth VRL program. Emit a warning instead
so users get actionable feedback rather than silent data loss.
@20agbekodo 20agbekodo force-pushed the josue.agbekodo/http_server_auth_write branch from d9b41bd to 7fb22d0 Compare May 19, 2026 22:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fb22d0200

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a87923123

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs
Comment thread src/sources/http_server.rs
Comment thread src/sources/http_server.rs Outdated
@20agbekodo 20agbekodo force-pushed the josue.agbekodo/http_server_auth_write branch from 1a87923 to 4127fa3 Compare May 20, 2026 22:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4127fa32ef

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/http/server_auth.rs
Comment thread src/sources/http_server.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29734f4395

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs Outdated
@20agbekodo 20agbekodo force-pushed the josue.agbekodo/http_server_auth_write branch from 29734f4 to eebce5d Compare May 22, 2026 14:35
@20agbekodo 20agbekodo requested a review from thomasqueirozb May 22, 2026 14:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eebce5da39

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/http/server_auth.rs Outdated
Comment thread website/cue/reference/components/sources/generated/http_server.cue Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f49b23b7f6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/http_server.rs
@20agbekodo 20agbekodo force-pushed the josue.agbekodo/http_server_auth_write branch from f49b23b to 7f2f564 Compare May 26, 2026 14:55
Comment thread src/sources/util/http/prelude.rs
@thomasqueirozb thomasqueirozb added source: http_server Anything `http_server` source related and removed docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels May 27, 2026
@20agbekodo 20agbekodo added this pull request to the merge queue May 27, 2026
Merged via the queue into vectordotdev:master with commit e5e2e15 May 27, 2026
105 of 106 checks passed
@20agbekodo 20agbekodo deleted the josue.agbekodo/http_server_auth_write branch May 27, 2026 18:35
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

domain: external docs Anything related to Vector's external, public documentation domain: sources Anything related to the Vector's sources source: http_server Anything `http_server` source related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants