ZeroFactor.Aspire.Hosting 0.1.6

dotnet add package ZeroFactor.Aspire.Hosting --version 0.1.6
                    
NuGet\Install-Package ZeroFactor.Aspire.Hosting -Version 0.1.6
                    
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="ZeroFactor.Aspire.Hosting" Version="0.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroFactor.Aspire.Hosting" Version="0.1.6" />
                    
Directory.Packages.props
<PackageReference Include="ZeroFactor.Aspire.Hosting" />
                    
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 ZeroFactor.Aspire.Hosting --version 0.1.6
                    
#r "nuget: ZeroFactor.Aspire.Hosting, 0.1.6"
                    
#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 ZeroFactor.Aspire.Hosting@0.1.6
                    
#: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=ZeroFactor.Aspire.Hosting&version=0.1.6
                    
Install as a Cake Addin
#tool nuget:?package=ZeroFactor.Aspire.Hosting&version=0.1.6
                    
Install as a Cake Tool

ZeroFactor.Aspire.Hosting

Aspire hosting integration for 0factor, a mock OIDC provider for local development. Login is an email address only. URLs, discovery, tokens and realm import are Keycloak-compatible, so swapping Keycloak for 0factor is one line in the AppHost.

Never use 0factor in production.

// dotnet add package ZeroFactor.Aspire.Hosting
var keycloak = builder.AddZeroFactor("keycloak")    // was: builder.AddKeycloak("keycloak", 8080)
    .WithRealmImport("./Realms")                    // same realm files Keycloak uses
    .WithDataVolume();

builder.AddProject<Projects.Web>("web")
    .WithReference(keycloak)
    .WaitFor(keycloak);

App projects keep the official Aspire.Keycloak.Authentication package unchanged:

builder.Services.AddAuthentication()
    .AddKeycloakOpenIdConnect("keycloak", realm: "shop", options => { /* ... */ });
Method Container
AddZeroFactor(name, port) docker.io/c4l3b/0factor:<package version>, endpoint http → 8080, health check /health
WithRealmImport(path) copies files to /opt/keycloak/data/import
WithDataVolume(name) / WithDataBindMount(source) mounts /data (holds 0factor.json)

Without port, the host port is derived from the AppHost directory and resource name (20000–29999): stable across restarts, and different for each AppHost on the machine, so several projects can run at once without coordinating ports. Pass port: 8080 to keep Keycloak's exact URL, or pass a port if two AppHosts ever collide.

Requires Aspire 13.4.6 or later. The endpoint is unproxied, so Aspire integration tests keep the port. For a port Aspire allocates on every run, use AddZeroFactor(name, port: null, isProxied: true). ZF_HOSTNAME is set automatically to the host endpoint; a later WithEnvironment can override it.

For apps using stock OIDC/JwtBearer handlers:

builder.AddProject<Projects.Web>("web")
    .WithReference(keycloak, realm: "shop")
    .WaitFor(keycloak);
// Web: builder.Configuration.GetConnectionString("keycloak") is the issuer.

This adds realm users and discovery links to the dashboard. The provider also links to user management. For a custom environment setting, use .WithEnvironment("Auth__Authority", keycloak.GetIssuer("shop")). Issuer references resolve to the allocated host address, intended for local project consumers.

See the main README for import precedence, explicit realm leniency, audience shorthand and migration from other mocks.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.6 44 10/15/2026
0.1.5 39 10/15/2026
0.1.4 44 10/15/2026
0.1.3 36 10/15/2026
0.1.2 43 10/14/2026
0.1.1 43 10/14/2026
0.1.0 37 10/14/2026