[HDX-5198] Accept both bearer token authorization header formats on ingest - #3027
Conversation
🦋 Changeset detectedLatest commit: 96176b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR extends standalone and OpAMP-managed OTLP authentication to recognize common
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/api/src/opamp/controllers/opampController.ts | Expands each managed ingestion key into the bare form and three common Bearer-prefixed forms before generating the collector authentication configuration. |
| docker/otel-collector/config.standalone.auth.yaml | Adds equivalent Bearer-prefixed values to standalone OTLP authentication while retaining the existing bare token. |
| packages/api/src/opamp/controllers/tests/opampController.test.ts | Verifies managed token expansion, all-in-one ingestion-key handling, receiver authentication wiring, and unchanged Datadog behavior. |
| smoke-tests/otel-collector/bearer-auth.bats | Exercises accepted bare and common Bearer-prefixed forms plus rejection of missing and incorrect credentials. |
| smoke-tests/otel-collector/docker-compose.yaml | Adds an isolated standalone authenticated collector service for end-to-end smoke coverage. |
| smoke-tests/otel-collector/setup_suite.bash | Includes the new authenticated collector in the smoke suite readiness sequence. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Client[OTLP client] --> Header[Authorization header]
Header --> Forms{Header value}
Forms -->|Bare key| Auth[Bearer-token authenticator]
Forms -->|Bearer / bearer / BEARER + key| Auth
Forms -->|Missing or incorrect key| Reject[Reject request]
Auth -->|Configured token matches| Receiver[OTLP receiver]
Receiver --> ClickHouse[(ClickHouse)]
Reviews (4): Last reviewed commit: "Merge branch 'main' into warren/HDX-5198..." | Re-trigger Greptile
E2E Test Results✅ All tests passed • 325 passed • 1 skipped • 1282s
Tests ran across 4 shards in parallel. |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Additional context: touches background tasks or the delivery pipeline lightly (6 lines, under the 30-line bar for Tier 4) Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
cda14f3 to
073231c
Compare
Deep Review✅ No critical issues found. This is a small, well-scoped auth change: 🔵 P3 nitpicks (3)
Reviewers: Testing gaps:
|
…5198) The bearertokenauth extension matches the full Authorization header value exactly, and both ingest auth surfaces (OpAMP-managed config and the standalone OTLP_AUTH_TOKEN config) listed only the bare token, so RFC 6750 clients that send 'Authorization: Bearer <token>' were rejected. Accept the Bearer, bearer, and BEARER prefixed forms alongside the bare token, and cover both paths with unit tests plus an end-to-end bearer-auth smoke suite.
073231c to
2a05ffc
Compare
Summary
Our OTel ingest endpoint only accepted the bare-token form of the
Authorizationheader, so RFC 6750 clients that sendAuthorization: Bearer <token>were rejected.Root cause: the contrib
bearertokenauthextension compares the full header value exactly againstscheme + " " + token(bare token whenscheme: ''), with no prefix-stripping or case-insensitive scheme handling. Sincetokensis a list, we enumerate the accepted forms explicitly:opampController.ts): newbearerTokenVariants()helper emits<key>,Bearer <key>,bearer <key>,BEARER <key>for each ingestion API key inbearertokenauth/hyperdx. TheDD-API-KEY-based datadog authenticator is intentionally unchanged (bare key only).config.standalone.auth.yaml): same four forms of${env:OTLP_AUTH_TOKEN}.Known limitation: exotic mixed-case schemes (e.g.
BeArEr) remain rejected — truly case-insensitive matching would require a custom Go authenticator. The enumerated variants cover the forms real clients send.Testing
buildOtelCollectorConfigassert the emitted token variants (team keys +INGESTION_API_KEY) and that the datadog authenticator stays bare-only.smoke-tests/otel-collector/bearer-auth.bats+otel-collector-bearer-authservice): bare andBearer-prefixed tokens accepted with data landing in ClickHouse,bearer/BEARERvariants accepted, wrong token and missing header rejected. All 7 tests pass locally against the real collector build.make ci-lintandmake ci-unitpass.How to test on Vercel preview
N/A — non-UI change.
References