Skip to content

feat(http_server source): Add bearer authentication strategy#25073

Open
steveduan-IDME wants to merge 6 commits intovectordotdev:masterfrom
steveduan-IDME:http_server_bearer
Open

feat(http_server source): Add bearer authentication strategy#25073
steveduan-IDME wants to merge 6 commits intovectordotdev:masterfrom
steveduan-IDME:http_server_bearer

Conversation

@steveduan-IDME
Copy link
Copy Markdown
Contributor

@steveduan-IDME steveduan-IDME commented Mar 30, 2026

Summary

This pull request adds support for bearer token authentication to HTTP server sources, allowing users to secure endpoints using the Authorization: Bearer <token> header. The implementation includes configuration, deserialization, matcher logic, and comprehensive tests for the new strategy.

Vector configuration

# vector.yaml
  sources:
    my_http:
      type: http_server
      address: "0.0.0.0:8080"
      encoding: text
      auth:
        strategy: bearer
        token: "my-secret-token"

  sinks:
    console:
      type: console
      inputs: ["my_http"]
      encoding:
        codec: json

How did you test this PR?

  # Start vector
  cargo run -- --config vector.yaml

  # 200 - correct token
  curl -X POST http://localhost:8080 \
    -H "Authorization: Bearer my-secret-token" \
    -H "Content-Type: text/plain" \
    -d "hello world"

  # 401 - wrong token
  curl -X POST http://localhost:8080 \
    -H "Authorization: Bearer wrong-token" \
    -d "hello"

  # 401 - missing header
  curl -X POST http://localhost:8080 -d "hello"

  And run the tests:

  # Unit tests
  cargo test --lib -p vector --no-default-features \
    --features "sources-http_server" -- common::http::server_auth

  # Integration tests
  cargo test --lib -p vector --no-default-features \
    --features "sources-http_server" -- sources::http_server::tests::returns_401_when_required_bearer
  cargo test --lib -p vector --no-default-features \
    --features "sources-http_server" -- sources::http_server::tests::http_post_with_correct_bearer_auth

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. This PR adds a new bearer authentication strategy to all HTTP server components (http_server, heroku_logs, websocket_server).
Users can now configure:

  auth:
    strategy: bearer
    token: "my-secret-token"

This is covered by the changelog fragment at changelog.d/http_server_bearer_auth.enhancement.md. The generated CUE docs will update
automatically when make generate-component-docs is run (which happens in CI).

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

@steveduan-IDME steveduan-IDME requested a review from a team as a code owner March 30, 2026 19:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions bot added the domain: sources Anything related to the Vector's sources label Mar 30, 2026
@steveduan-IDME steveduan-IDME changed the title Made http_server source to support Bearer authentication feat(http_server source): Add bearer authentication strategy Mar 30, 2026
  - feat — new feature (new auth strategy)
  - http_server source — scope matching the component
  - Description is concise

Co-Authored-By: Claude Code
@steveduan-IDME steveduan-IDME changed the title feat(http_server source): Add bearer authentication strategy feat(http_server): Add bearer authentication strategy Mar 31, 2026
Copy link
Copy Markdown
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

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

Hi @steveduan-IDME, you need to run make generate-component-docs to regenerate documentation for the sinks too.

@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Apr 2, 2026
Co-authored-by: Thomas <thomasqueirozb@gmail.com>
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Apr 3, 2026
@steveduan-IDME steveduan-IDME changed the title feat(http_server): Add bearer authentication strategy feat(http_server source): Add bearer authentication strategy Apr 3, 2026
@steveduan-IDME
Copy link
Copy Markdown
Contributor Author

@thomasqueirozb I had run make generate-component-docs but it didn't generate any new docs.
Also any pointer how can I to fix the above Check Spelling / Check Spelling (pull_request_target) error?

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

Labels

domain: sources Anything related to the Vector's sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make http_server source to support Bearer authentication

2 participants