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
<PackageReference Include="ZeroFactor.Aspire.Hosting" Version="0.1.6" />
<PackageVersion Include="ZeroFactor.Aspire.Hosting" Version="0.1.6" />
<PackageReference Include="ZeroFactor.Aspire.Hosting" />
paket add ZeroFactor.Aspire.Hosting --version 0.1.6
#r "nuget: ZeroFactor.Aspire.Hosting, 0.1.6"
#:package ZeroFactor.Aspire.Hosting@0.1.6
#addin nuget:?package=ZeroFactor.Aspire.Hosting&version=0.1.6
#tool nuget:?package=ZeroFactor.Aspire.Hosting&version=0.1.6
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 | Versions 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. |
-
net10.0
- Aspire.Hosting (>= 13.4.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.