Table of Contents

Class NuGetAuthHandler

Namespace
Virtufin.WorkManager.Components
Assembly
Virtufin.WorkManager.dll

HTTP message handler that injects HTTP Basic credentials into outbound requests to the configured NuGet registry. Used by the WorkManager's IHttpClientFactory-managed CodeFetcher client so it can download worker .nupkg artefacts from a private Gitea NuGet registry (e.g. https://gitea.haenerconsulting.com/api/packages/virtufin/nuget/package/...) without requiring public-read access on the registry.

public sealed class NuGetAuthHandler : DelegatingHandler, IDisposable
Inheritance
NuGetAuthHandler
Implements
Inherited Members

Remarks

Credentials are read from environment variables at handler construction:

  • VIRTUFIN_NUGET_USERNAME — typically buildbot.
  • VIRTUFIN_NUGET_API_KEY — the Gitea personal access token with read:package + write:package scopes.

The handler only injects the Authorization header for requests whose URL host matches one of the configured RegistryHosts (case-insensitive exact match). Requests to other hosts are passed through unchanged, so non-NuGet code-source URLs do not leak credentials. The default list is nuget.haenerconsulting.com (the legacy DNS name pointing at the same Gitea backend) and gitea.haenerconsulting.com (the canonical Gitea host).

This is intentionally scoped: a future move to a different registry (e.g. nuget.org, GitHub Packages) only needs a handler variant or a richer routing config — the public IHttpClientFactory consumer in WorkManager.FetchFromUrlAsync is unchanged.

Constructors

NuGetAuthHandler(string)

public NuGetAuthHandler(string registryHost)

Parameters

registryHost string

NuGetAuthHandler(string[])

public NuGetAuthHandler(string[] registryHosts)

Parameters

registryHosts string[]

Fields

DefaultRegistryHosts

Default host patterns for the project's NuGet registry. Both names point at the same Gitea backend (one is a DNS alias of the other).

public static readonly string[] DefaultRegistryHosts

Field Value

string[]

Properties

RegistryHosts

public IReadOnlyList<string> RegistryHosts { get; }

Property Value

IReadOnlyList<string>

Methods

SendAsync(HttpRequestMessage, CancellationToken)

Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

Parameters

request HttpRequestMessage

The HTTP request message to send to the server.

cancellationToken CancellationToken

A cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

ArgumentNullException

The request was null.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.