Skip to content

feat(core): unified HTTP auth provider + custom headers + CVP fix#522

Merged
JusterZhu merged 3 commits into
masterfrom
release/10.5.0-beta.3
Jun 19, 2026
Merged

feat(core): unified HTTP auth provider + custom headers + CVP fix#522
JusterZhu merged 3 commits into
masterfrom
release/10.5.0-beta.3

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

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

  • Add DefaultAuthProvider property — single source of truth for global auth
  • Add ExtraHeaders ConcurrentDictionary — attach custom headers (e.g. X-Tenant-Id) to every request without writing a custom IHttpAuthProvider
  • Add ApplyAuthAsync() — applies both the auth provider and extra headers

VersionService

  • _globalAuthProvider → delegates to HttpClientProvider.DefaultAuthProvider
  • Rename fields for clarity: _auth_authProvider, _maxRetries_maxRetryAttempts, IsRetryableShouldRetry
  • Rename constructor parameters: authauthProvider, timeoutrequestTimeout, maxRetriesmaxRetryAttempts

HttpUpdateReporter

  • Use HttpClientProvider.Shared instead of new HttpClient()
  • Apply global auth provider before sending via HttpClientProvider.ApplyAuthAsync()

AbstractBootstrap

  • Add HttpAuth(IHttpAuthProvider instance) overload — allows registering providers with constructor parameters

UpdateConfiguration

  • Add CustomHeaders dictionary — set custom HTTP headers via config, synced to HttpClientProvider.ExtraHeaders in SetConfig()

Changes (GeneralSpacestation server)

UpgradeService.BuildUnifiedResponseAsync

  • Remove Version == lastVersion hard constraint on CVP matching
  • Now accepts any CVP whose FromVersion == clientVersion with valid archive hashes, preferring the highest target version
  • Client SDK (DownloadPlanBuilder) handles CVP + chain mixed path

Changes (test)

ClientTest

  • Use SetConfig(UpdateRequest { CustomHeaders = ... }) instead of manual header assignment
  • Fix manifest productId to match test data

AOT 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.

- 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>
Copilot AI review requested due to automatic review settings June 19, 2026 16:42

Copilot AI left a comment

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.

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, and ApplyAuthAsync() to apply global auth + headers consistently.
  • Updates VersionService and HttpUpdateReporter to use the unified global auth provider and shared HttpClient.
  • Adds CustomHeaders to 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.

Comment thread src/c#/GeneralUpdate.Core/Network/HttpClientProvider.cs
Comment thread src/c#/GeneralUpdate.Core/Configuration/UpdateConfiguration.cs
Comment thread src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs
Comment thread tests/ClientTest/Program.cs
Comment thread src/c#/GeneralUpdate.Core/Network/HttpClientProvider.cs
JusterZhu and others added 2 commits June 20, 2026 01:01
- 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>
@JusterZhu
JusterZhu merged commit 55bdfde into master Jun 19, 2026
3 checks passed
@JusterZhu
JusterZhu deleted the release/10.5.0-beta.3 branch June 19, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants