Skip to content

Bearer token authentication for downloading remote registries#1356

Open
jerbly wants to merge 9 commits intoopen-telemetry:mainfrom
jerbly:http-pull
Open

Bearer token authentication for downloading remote registries#1356
jerbly wants to merge 9 commits intoopen-telemetry:mainfrom
jerbly:http-pull

Conversation

@jerbly
Copy link
Copy Markdown
Contributor

@jerbly jerbly commented Apr 14, 2026

Adds HTTP Bearer token authentication for downloading remote registries from private HTTP(S) sources (closes #1344). Primary use case: pulling published registry artifacts (manifest.yaml + resolved.yaml) from private GitHub release assets.

  • New RemoteFile source type for VirtualDirectoryPath - supports non-archive, non-git HTTP(S) URLs.
  • HTTP auth via WEAVER_HTTP_AUTH_TOKEN or GITHUB_TOKEN env var. Adds Authorization: Bearer and User-Agent: weaver headers to remote downloads.
  • GitHub URL normalization - browser-style URLs like https://github.com/org/repo/releases/download/v1.0.0/manifest.yaml are transparently resolved to GitHub API asset URLs (which accept Bearer auth). Release metadata is cached per-release to avoid redundant API calls.
  • Shared ureq Agent with RedirectAuthHeaders::SameHost so auth headers survive GitHub's same-host redirects but are stripped on cross-origin redirects.

Breaking change: A bare HTTP(S) URL with no .git/.zip/.tar.gz suffix and no refspec or [sub_folder] now parses as RemoteFile instead of GitRepo. Add .git to such URLs to keep the old behaviour.

@jerbly jerbly requested a review from a team as a code owner April 14, 2026 00:35
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 94.07895% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.1%. Comparing base (be6d4a7) to head (b505b4c).

Files with missing lines Patch % Lines
crates/weaver_common/src/test.rs 89.6% 6 Missing ⚠️
crates/weaver_common/src/vdir.rs 96.8% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1356     +/-   ##
=======================================
+ Coverage   81.8%   82.1%   +0.2%     
=======================================
  Files        114     114             
  Lines       9803    9931    +128     
=======================================
+ Hits        8025    8157    +132     
+ Misses      1778    1774      -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

/// Optional Bearer token for authenticating HTTP requests when downloading
/// remote archives and files. Set via `set_http_auth_token()`, typically from
/// the `WEAVER_HTTP_AUTH_TOKEN` or `GITHUB_TOKEN` environment variable at startup.
static HTTP_AUTH_TOKEN: Mutex<Option<String>> = Mutex::new(None);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this work if we start having multi-threaded servers using the weaver engine?

Could we wind up with conflicts for using both HTTP and GITHUB urls at the same time?

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.

I don't think I follow. You can only have one token with this implementation, do you mean that we may need different tokens to fetch different dependencies?

Regarding URLs, the type is detected for each download.

//! # Disambiguating HTTP(S) URLs
//!
//! An HTTP(S) `source` is classified as follows (in order):
//! 1. `.zip` or `.tar.gz` suffix → remote archive (may carry a `[sub_folder]`).
//! 2. `.git` suffix, or presence of `@refspec` or `[sub_folder]` → Git repo. Once
//!    archives are ruled out, a `@refspec` or `[sub_folder]` is a reliable signal
//!    of a Git repo, so the `.git` suffix is not required.
//! 3. Otherwise → remote file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes - the idea we need different for different dependencies, or, e.g. where we're pulling in schema_url dynamically in live-check

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.

Oof! That will be really ugly - is that realistic? In my case it's company reg depends on otel reg: company needs token, otel does not. This would work today.

We could have company->company->company...->otel too, the same token would be valid in all those private locations.

We'd have to have env vars associated with each private location. I guess that's doable if we think it's needed?? Perhaps defer to another issue/pr later?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See - https://doc.rust-lang.org/cargo/reference/config.html#credentials or https://maven.apache.org/settings.html#Servers

I think once your weaver.toml stuff lands this would be a good spot for it.

@jsuereth jsuereth moved this to To consider for the next release in OTel Weaver Project Apr 15, 2026
Copy link
Copy Markdown
Contributor

@jsuereth jsuereth left a comment

Choose a reason for hiding this comment

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

I believe there is a non-breaking way to support multiple credentials per-domain you resolve from and this flag at the same time.

Specifically I think we can have a url - token config, similar to cargo, in the future that would "win" over this broad credential config.

Approve-ing but want to confirm you agree with me first, @jerbly. WDYT?

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

Labels

None yet

Projects

Status: To consider for the next release

Development

Successfully merging this pull request may close these issues.

Support securely pulling artifacts over http

2 participants