feat(core): unified HTTP auth provider + custom headers + CVP fix#522
Merged
Conversation
- HttpClientProvider: add DefaultAuthProvider, ExtraHeaders, ApplyAuthAsync() - VersionService: delegate _globalAuthProvider to HttpClientProvider; rename fields (_auth->_authProvider, _maxRetries->_maxRetryAttempts, IsRetryable->ShouldRetry) + constructor parameter rename - HttpUpdateReporter: use HttpClientProvider.Shared instead of new HttpClient(); apply global auth provider before sending - AbstractBootstrap: add HttpAuth(IHttpAuthProvider) instance overload - UpdateConfiguration: add CustomHeaders dictionary for tenant/extra headers - ConfigurationMapper: map CustomHeaders field - SetConfig: auto-sync CustomHeaders to HttpClientProvider.ExtraHeaders - ClientTest: use SetConfig with CustomHeaders instead of manual header; fix manifest productId to match test data Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Unifies HTTP authentication and request header injection across GeneralUpdate.Core request paths (validation + reporting) by centralizing global auth and extra headers in HttpClientProvider, and updates the client test configuration to use the new config-based header/auth flow.
Changes:
- Introduces
HttpClientProvider.DefaultAuthProvider,ExtraHeaders, andApplyAuthAsync()to apply global auth + headers consistently. - Updates
VersionServiceandHttpUpdateReporterto use the unified global auth provider and sharedHttpClient. - Adds
CustomHeadersto configuration and syncs config headers into the global HTTP layer; updates test manifest + client test setup accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ClientTest/Program.cs | Switches test to SetConfig(UpdateRequest { ... CustomHeaders ... }) and sets Basic auth in config. |
| tests/ClientTest/generalupdate.manifest.json | Updates productId to match expected test data. |
| src/c#/GeneralUpdate.Core/Network/VersionService.cs | Renames fields for clarity and delegates global auth to HttpClientProvider.DefaultAuthProvider. |
| src/c#/GeneralUpdate.Core/Network/HttpClientProvider.cs | Adds global default auth provider, extra headers store, and a helper to apply them to requests. |
| src/c#/GeneralUpdate.Core/Download/Reporting/IUpdateReporter.cs | Uses shared HttpClientProvider.Shared and applies global auth/headers before report POSTs. |
| src/c#/GeneralUpdate.Core/Configuration/UpdateConfiguration.cs | Adds CustomHeaders to the shared configuration base class. |
| src/c#/GeneralUpdate.Core/Configuration/ConfigurationMapper.cs | Maps CustomHeaders from UpdateRequest to UpdateContext. |
| src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs | Adds overload to register a pre-constructed IHttpAuthProvider instance. |
| src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs | Syncs CustomHeaders into HttpClientProvider.ExtraHeaders during SetConfig(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unused using System.Linq from HttpClientProvider - Handle content headers (Content-Type etc.) in ApplyAuthAsync to avoid InvalidOperationException from HttpRequestHeaders - Clarify doc comment on CustomHeaders: can override auth headers - Clear stale synced headers on repeated SetConfig calls to avoid leaks - Restore APP_SECRET_KEY env var fallback in ClientTest - Add ContentHeaderNames set for content-vs-request header routing Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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
Unify HTTP authentication across all request paths (Verification + Report), add custom headers support to UpdateConfiguration, and fix CVP cross-version decision logic in GeneralSpacestation.
Changes (GeneralUpdate.Core library)
HttpClientProvider
DefaultAuthProviderproperty — single source of truth for global authExtraHeadersConcurrentDictionary — attach custom headers (e.g.X-Tenant-Id) to every request without writing a custom IHttpAuthProviderApplyAuthAsync()— applies both the auth provider and extra headersVersionService
_globalAuthProvider→ delegates toHttpClientProvider.DefaultAuthProvider_auth→_authProvider,_maxRetries→_maxRetryAttempts,IsRetryable→ShouldRetryauth→authProvider,timeout→requestTimeout,maxRetries→maxRetryAttemptsHttpUpdateReporter
HttpClientProvider.Sharedinstead ofnew HttpClient()HttpClientProvider.ApplyAuthAsync()AbstractBootstrap
HttpAuth(IHttpAuthProvider instance)overload — allows registering providers with constructor parametersUpdateConfiguration
CustomHeadersdictionary — set custom HTTP headers via config, synced toHttpClientProvider.ExtraHeadersinSetConfig()Changes (GeneralSpacestation server)
UpgradeService.BuildUnifiedResponseAsync
Version == lastVersionhard constraint on CVP matchingFromVersion == clientVersionwith valid archive hashes, preferring the highest target versionChanges (test)
ClientTest
SetConfig(UpdateRequest { CustomHeaders = ... })instead of manual header assignmentproductIdto match test dataAOT compatibility
All changes are static-analyzed at compile time — no reflection, no Activator, no DynamicCode. Existing AOT warnings are pre-existing.
Design
The global auth provider now lives in
HttpClientProvider:SetDefaultAuthProvider()one call, both Verification and Report paths covered. Extra headers are a first-class config property, not glue code.