ZiAuthenticatorTool 1.0.0
dotnet add package ZiAuthenticatorTool --version 1.0.0
NuGet\Install-Package ZiAuthenticatorTool -Version 1.0.0
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="ZiAuthenticatorTool" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZiAuthenticatorTool" Version="1.0.0" />
<PackageReference Include="ZiAuthenticatorTool" />
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 ZiAuthenticatorTool --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZiAuthenticatorTool, 1.0.0"
#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 ZiAuthenticatorTool@1.0.0
#: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=ZiAuthenticatorTool&version=1.0.0
#tool nuget:?package=ZiAuthenticatorTool&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ZiAuthenticatorTool
Lightweight ASP.NET Core authentication middleware extension for plugging in a custom authenticator.
Dependencies
- .NET target framework:
net10.0 - NuGet packages:
Microsoft.AspNetCore.Http.Abstractions(2.3.9)Microsoft.Extensions.DependencyInjection.Abstractions(10.0.3)
- Runtime context: ASP.NET Core app using DI + middleware pipeline
Usage
Register your authenticator in DI:
services.AddZiAuthenticatorTool<YourAuthenticator>(options =>
{
options.UseScheme(Scheme.Basic); // or Scheme.Bearer
options.SetItemKey("Z-Auth-Result");
});
Enable middleware in the app pipeline:
app.UseZiAuthenticatorTool();
Required API surface:
IServiceCollection.AddZiAuthenticatorTool<T>()IApplicationBuilder.UseZiAuthenticatorTool()
End-to-end example
1) Create a result model and authenticator
using ZiAuthenticatorTool;
using ZiAuthenticatorTool.Entity;
public sealed class DemoAuthResult : IResult
{
public required string Username { get; init; }
public required string Role { get; init; }
}
public sealed class DemoBasicAuthenticator : BasicAuthentication<DemoAuthResult>
{
protected override Task<DemoAuthResult?> AuthenticateAsync(BasicRequest request)
{
// Demo only: replace with your own user store / credential validation.
if (request.Username == "admin" && request.Password == "secret")
{
return Task.FromResult<DemoAuthResult?>(new DemoAuthResult
{
Username = request.Username,
Role = "Administrator"
});
}
return Task.FromResult<DemoAuthResult?>(null);
}
}
2) Register and use in Program.cs
using ZiAuthenticatorTool;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddZiAuthenticatorTool<DemoBasicAuthenticator>(options =>
{
options.UseScheme(Scheme.Basic);
options.SetItemKey("Z-Auth-Result");
});
var app = builder.Build();
app.UseZiAuthenticatorTool();
app.MapGet("/secure", (HttpContext ctx) =>
{
if (ctx.Items["Z-Auth-Result"] is not DemoAuthResult user)
{
return Results.Unauthorized();
}
return Results.Ok(new
{
message = $"Hello {user.Username}",
role = user.Role
});
});
app.Run();
3) Call the endpoint with Basic auth
curl -i -H "Authorization: Basic YWRtaW46c2VjcmV0" http://localhost:5000/secure
YWRtaW46c2VjcmV0 is Base64 for admin:secret.
License
MIT
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
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 |
|---|---|---|
| 1.0.0 | 133 | 3/14/2026 |