Keys Api
The Vault at the Heart of Your Platform
ASP.NET
Arch is built on the ASP.NET platform. To get started with the Keys Api, add its NuGet package to your program, register it with the service collection, and work with its client.
NuGet Setup
Add NuGet package TriunniaLabs.Arch.Api.Keys.Client to your project.

Note that we use our own NuGet package feed, which you must add as a package source in your environment.
Service Setup
In the main Service Composition section of your program startup, make the call to AddTriunniaLabsKeysApi() to add the Keys Api. This reads the KeysApi configuration section, registers the Keys Api client with its resilience policies, and provides a callback for its types to be registered with the message formatter.
builder.Services.AddTriunniaLabsKeysApi(builder.Configuration, builder.Services.AddStandardMessagePackFormatters);
See: Program.cs
Accessing the Keys Api
Access the Keys Api by injecting the IKeysApiClient.

See KeysApiSampleController.cs for examples of how to use its functions. Note that all parameters passed to these functions must be Protected Types (Protected<T>).
Aspire
If using Aspire, add this extension method to your solution to install the Keys Api in the Aspire solution. Set the correct version number, fill in the environment variables, ensure the bind mount path is accurate, and make any other changes as required.
public static void AddKeysApi(this IDistributedApplicationBuilder builder, IResourceBuilder<SqlServerServerResource> sqlServer) { var keysApiDb = sqlServer.AddDatabase("KeysApiDb"); var keysApi = builder.AddContainer("KeysApi", "gitea.triunnialabs.com/triunnialabs/arch-keys-api", "0.1.18") .WithEndpoint(50002, 8080, isProxied: false, name: "http") .WithEndpoint("http", e => e.TargetHost = "0.0.0.0") // Obtain the values for these fields from the Control Panel .WithEnvironment("Microservice__Name", "") .WithEnvironment("Microservice__EnvelopePassword", "") .WithEnvironment("Microservice__EnableDiagnostics", "true") // Set to false in production deployments .WithEnvironment("Microservice__Application__Url", "") .WithEnvironment("Microservice__Application__ApplicationId", "") .WithEnvironment("Microservice__Application__ApiKey", "") .WithEnvironment("Microservice__Application__EnvelopePassword", "") .WithEnvironment("Microservice__ProtectedMemory__HmacSha512HashKey", "") .WithEnvironment("Microservice__ProtectedMemory__AesEncryptionPassword", "") .WithEnvironment("Microservice__ProtectedMemory__AesEncryptionSalt", "") .WithEnvironment("Microservice__ProtectedMemory__AesEncryptionIterations", "") .WithEnvironment("SqlServer__ConnectionString", "") .WithEnvironment("SqlServer__ReadOnlyConnectionString", "") // Api will write log and other files to this relative source folder .WithBindMount("..\\..\\..\\data\\KeysApi", "/opt/triunnialabs/arch/keys-api") .WithReference(keysApiDb) .WaitFor(keysApiDb) }
See: KeysApiSetup.cs
Tech Sovereignty
Arch
Company
About Contact