VOOZH about

URL: https://www.nuget.org/packages/Vorn.Aaas.Client.Api/

⇱ NuGet Gallery | Vorn.Aaas.Client.Api 9.1.2




Vorn.Aaas.Client.Api 9.1.2

dotnet add package Vorn.Aaas.Client.Api --version 9.1.2
 
 
NuGet\Install-Package Vorn.Aaas.Client.Api -Version 9.1.2
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Vorn.Aaas.Client.Api" Version="9.1.2" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vorn.Aaas.Client.Api" Version="9.1.2" />
 
Directory.Packages.props
<PackageReference Include="Vorn.Aaas.Client.Api" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Vorn.Aaas.Client.Api --version 9.1.2
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Vorn.Aaas.Client.Api, 9.1.2"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Vorn.Aaas.Client.Api@9.1.2
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Vorn.Aaas.Client.Api&version=9.1.2
 
Install as a Cake Addin
#tool nuget:?package=Vorn.Aaas.Client.Api&version=9.1.2
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Vorn.Aaas.Client.Api

Lightweight .NET 8 library for consuming VORN AAAS-protected APIs from your ASP.NET Core applications.

It provides DI-ready services that:

  • Register with a single extension AddAaasApiClient.
  • Acquire OAuth2 client-credentials access tokens using Duende IdentityModel.
  • Cache tokens in-memory and refresh them proactively.
  • Attach owner/client context headers per request.
  • Create HttpClient instances preconfigured with base address and bearer tokens.

Packages and target framework

  • Target framework: .NET 8
  • Uses Duende IdentityModel and Microsoft.Extensions.*

Getting started

  1. Add a project reference to Vorn.Aaas.Client.Api from your web/API project.

  2. Configure options in appsettings.json under the Vorn:Aaas section.

  3. Call AddAaasApiClient on your WebApplicationBuilder and inject the services you need.

Configuration

Add the following section to your configuration (appsettings.json, user secrets, or environment variables):

{
 "Vorn": {
 "Aaas": {
 "Authority": "https://auth.yourdomain.tld",
 "Secret": "your-access-client-secret",
 "ClientId": "your-default-owner-client-id",
 "Local": null,
 "DataProtectionDomain": null,
 "DataProtectionPassword": null,
 "CookieExpirationDays": 14
 }
 }
}

Notes:

  • Authority is your AAAS authority/STS base URL.
  • Secret is used by the internal access client (see AaasConstants.AccessClient).
  • ClientId is an optional default owner/client id used when no explicit owner is set.
  • Local (any non-null value) appends a .local suffix to resolved API client ids (used by IApiClientService).

Environment variables (example):

  • Vorn__Aaas__Authority
  • Vorn__Aaas__Secret
  • Vorn__Aaas__ClientId
  • Vorn__Aaas__Local

Registering services

In Program.cs:

var builder = WebApplication.CreateBuilder(args);

// Registers options and the AAAS client services
builder.AddAaasApiClient();

var app = builder.Build();
app.Run();

This registers:

  • IAaasClientFactory for generic AAAS-backed clients.
  • IApiClientService for endpoint-specific API clients discovered by endpoint naming.
  • IOwnerContext for per-request owner/client id handling.

Usage

1) Create a client for an AAAS endpoint using IAaasClientFactory

public class MyService(IAaasClientFactory factory)
{
 public async Task<HttpResponseMessage> GetAsync()
 {
 // Optional: provide endpoint path and an overriding owner client id
 using var client = await factory.CreateClient("/api/resource/", clientId: "owner.client.id");
 return await client.GetAsync("items");
 }
}

Behavior:

  • Base address: Authority combined with the provided endpoint via UrlExtensions.UrlCombine.
  • Header added: Content-Owner (when available).
  • Bearer token is automatically acquired and attached.

2) Create a client for a specific API using IApiClientService

IApiClientService resolves an ApiClient by the last segment of the endpoint. For example, for endpoint /api/orders/, it looks up client id api.orders (or api.orders.local when Vorn:Aaas:Local is set).

public class OrdersService(IApiClientService apiClientService)
{
 public async Task<IReadOnlyList<Order>> GetOrdersAsync()
 {
 using var client = await apiClientService.CreateClient("/api/orders/");
 var response = await client.GetAsync("list");
 response.EnsureSuccessStatusCode();
 return await response.Content.ReadFromJsonAsync<List<Order>>() ?? [];
 }
}

Behavior:

  • Discovers ApiClient (id, secret, scopes, hostUri) via AAAS at /api/apiclients/{clientId}.
  • Acquires a client-credentials token for the discovered client.
  • Base address: https://{HostUri} combined with the provided endpoint.
  • Header added: Content-Owner (when available).

3) Manually retrieving an access token

public class TokenService(IApiClientService apiClientService)
{
 public async Task<string> GetTokenAsync()
 {
 var apiClient = await apiClientService.GetApiClient("api.orders")
 ?? throw new InvalidOperationException("Client not found");
 return await apiClientService.GetAccessTokenAsync(apiClient)
 ?? throw new InvalidOperationException("Token unavailable");
 }
}

4) Register and create SignalR hub connections

Implement ISignalRClientDefinition on your hub client to provide its default registration. Use AddSignalRClient only when you need to customize the defaults, and ISignalRClientFactory to create connections with AAAS headers and access tokens applied automatically.

builder.Services
 .AddAaasApiClient(builder.Configuration)
 .AddSignalRClient<FileTransferHub>();

public class FileTransferHub(ISignalRClientFactory connectionFactory) : ISignalRClientDefinition
{
 public static void Configure(SignalRClientRegistration registration)
 {
 registration.ClientId = "/files";
 registration.ResourceId = "/hubs/transfer";
 }

 public Task<HubConnection> CreateAsync(CancellationToken cancellationToken = default) =>
 connectionFactory.CreateConnection<FileTransferHub>(cancellationToken);
}

// Usage example
HubConnection connection = await connectionFactory.CreateConnection<FileTransferHub>();
await connection.StartAsync();

SignalRClientRegistration automatically resolves the AAAS API client based on the configured client id (override with ApiClientId if necessary), composes the hub path as /{clientId}/{resourceId}, applies owner headers, and configures reconnects and MessagePack by default. Customize the registration by calling AddSignalRClient<FileTransferHub>(options => { ... }) or tweak the underlying SignalR builder through the ConfigureBuilder and ConfigureHttpConnection delegates when additional options are required.

Per-connection adjustments are also supported through ISignalRClientFactory:

HubConnection connection = await connectionFactory.CreateConnection<FileTransferHub>(
 new SignalRConnectionOptions
 {
 UseMessagePack = false,
 ConfigureBuilder = builder => builder.WithAutomaticReconnect(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5) })
 });

Headers

  • Content-Owner header is sent by clients created via IAaasClientFactory and IApiClientService.

Make sure your downstream APIs expect and authorize these headers as needed.

Token caching and concurrency

  • Tokens are cached via Redis using IDistributedCache.
  • Proactive refresh: tokens are refreshed 60 seconds before expiry.
  • Concurrent requests are synchronized with a per-service SemaphoreSlim to avoid token stampedes.

Errors and diagnostics

  • Missing or invalid configuration throws InvalidOperationException during startup.
  • Discovery or token acquisition failures throw detailed exceptions including the underlying protocol error.
  • HttpResponseMessage.EnsureSuccessStatusCode() is used where appropriate; handle exceptions accordingly.

Development and configuration tips

  • Use ASP.NET Core user secrets for local development instead of committing secrets to source control.
  • Environment variable mapping uses double underscores: Vorn__Aaas__Secret, etc.
  • Setting Vorn:Aaas:Local to any non-null value appends .local to resolved API client ids (useful for local stacks).

Public surface

  • BuilderExtensions.AddAaasApiClient
  • IAaasClientFactory / AaasClientFactory
  • IApiClientService / ApiClientService
  • ISignalRClientFactory / SignalRClientFactory
  • IOwnerContext / OwnerContext
  • VornOptions, AaasOptions, ApiClientDto
  • SignalRClientRegistration, SignalRClientOptions
  • AaasConstants, UrlExtensions

Contributing

Issues and contributions are welcome. Please include a clear description and, if possible, a minimal reproduction.

Security

Store secrets securely (Key Vault, environment variables, or user secrets). Do not store secrets in source control.

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Vorn.Aaas.Client.Api:

Package Downloads
Vorn.Aaas.Client

This library is designed as part of web applications which are clients who get authentication as a service from Vorn.Aaas.Server.

Vorn.Files.Client

This library is designed as part of web applications which are clients who get file hosting as a service from a Vorn.Files.Host.

Vorn.Caas.Client

This library is designed as a client for Vorn Caas.

Vorn.Ai.Client

This library contains methods required to use VORN AI services.

Vorn.Ai.Client.Components

This library contains methods required to use AI services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.2 407 11/16/2025
9.1.1 306 11/15/2025
9.1.0 240 11/15/2025
9.0.2 591 11/10/2025
9.0.1 291 11/9/2025
9.0.0 329 11/5/2025
8.9.7 293 11/30/2025
8.9.6 359 11/30/2025
8.9.5 345 11/30/2025
8.9.4 288 11/29/2025
8.9.3 241 11/29/2025
8.9.2 279 11/23/2025
8.9.1 274 11/23/2025
8.9.0 330 11/9/2025
8.8.0 338 11/2/2025
8.7.1 312 10/29/2025
8.7.0 340 10/27/2025
8.6.2 331 10/27/2025
8.6.1 276 10/25/2025
8.6.0 275 10/25/2025
Loading failed