fix(client): fix OAuth2 authentication for logs commands#133
Draft
robhughadams wants to merge 1 commit intodatadog-labs:mainfrom
Draft
fix(client): fix OAuth2 authentication for logs commands#133robhughadams wants to merge 1 commit intodatadog-labs:mainfrom
robhughadams wants to merge 1 commit intodatadog-labs:mainfrom
Conversation
Fixes OAuth2 authentication for logs search, list, query, and aggregate commands by moving bearer token injection into a shared middleware layer and removing the incorrect exclusion of logs endpoints from OAuth support (closes datadog-labs#72). Implementation: - Add BearerTokenMiddleware to fork of datadog-api-client-rust for uniform bearer token injection across all commands - Replace 155 dual-path make_bearer_client()/with_config() patterns with single with_client_and_config(dd_cfg, make_dd_client(cfg)) call - Remove logs endpoints from OAUTH_EXCLUDED_ENDPOINTS (52→41 patterns) - Simplify logs search() and aggregate(): remove raw HTTP bearer fallback - Add --storage parameter wired to LogsStorageTier enum for all log commands - Update [patch.crates-io] to point at robhughadams/datadog-api-client-rust fork Commit Stats: - 41 files changed, 2973 insertions(+), 807 deletions(-) - 334 lines net reduction (from 807 deletions - 473 additions) - All 4 validation checks pass: cargo build, cargo fmt, cargo clippy, binary test Co-Authored-By: Robert Adams <robhughadams@gmail.com>
Contributor
Author
|
This PR requires DataDog/datadog-api-client-rust#1288 to be merged so that the mainstream DD client can be used before review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix OAuth2 bearer token authentication for logs commands by implementing unified middleware-based token injection in the forked
datadog-api-client-rust. Refactors all 34 command modules to use a singlemake_dd_client()function, eliminating dual-path bearer auth logic and fixing issue #72 ("Can't query logs with OAuth").Changes
Fork (
robhughadams/datadog-api-client-rust):src/datadog/middleware.rs(new): ImplementsBearerTokenMiddlewareto inject bearer tokens at the HTTP middleware layersrc/datadog/configuration.rs: Addedbearer_token: Option<String>field,set_bearer_token()setter, andDD_ACCESS_TOKENenv var supportsrc/datadog/mod.rs: ExportedBearerTokenMiddlewareCargo.toml: Addedasync-traitandtask-local-extensionsdependenciespup refactor (34 command modules):
src/client.rs: RemovedBearerAuthMiddlewareandmake_bearer_client(); addedmake_dd_client()that always returnsClientWithMiddlewarewith bearer middleware attached when token present; removed 11 endpoints fromOAUTH_EXCLUDED_ENDPOINTS(logs endpoints no longer need exclusion)src/commands/logs.rs: Simplifiedsearch()andaggregate()by removing raw HTTP bearer fallback; addedstorage: Option<String>parameter to search/list/query/aggregate commands for Flex Storage supportsrc/main.rs: Updated log command routing to passstorageargument through to all dispatch sitesmake_dd_client()callCargo.toml: Updated[patch.crates-io]to use remote fork:git = "https://github.com/robhughadams/datadog-api-client-rust", branch = "master"Build verification: ✓
cargo buildpasses with remote fork dependencyRelated Issues
Closes #72
Branch:
refactor/unified-oauth-middlewareFork: https://github.com/robhughadams/datadog-api-client-rust