AuthZen.AspNetCore
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package AuthZen.AspNetCore --version 1.0.0
NuGet\Install-Package AuthZen.AspNetCore -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="AuthZen.AspNetCore" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AuthZen.AspNetCore" Version="1.0.0" />
<PackageReference Include="AuthZen.AspNetCore" />
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 AuthZen.AspNetCore --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AuthZen.AspNetCore, 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 AuthZen.AspNetCore@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=AuthZen.AspNetCore&version=1.0.0
#tool nuget:?package=AuthZen.AspNetCore&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AuthZen-AspNetCore
Lightweight fine-grained authorization library for ASP.NET Core using the AuthZen protocol.
AuthZen.AspNetCore provides a simple, protocol-driven way to protect your ASP.NET Core microservices by delegating access decisions to a central authorization service.
Table of Contents
- Installation
- DI / Program.cs Setup
- Controller Usage with Attribute
- Optional UserId Override
- Configuration via appsettings.json
- Example Microservice Flow
- Quick Start Microservice Example
- License
Installation
Install the NuGet package in your microservice:
dotnet add package AuthZen.AspNetCore
DI / Program.cs Setup
Register AuthZen in any microservice:
using AuthZen.AspNetCore.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Register AuthZen authorization
builder.Services.AddAuthZenAuthorization(options =>
{
// Full URL to your central AuthZen authorization service
options.FullUrl = "https://auth-service.local/api/access/check";
});
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
Notes:
FullUrl should point to your central AuthZen authorization service.
The library automatically handles DI for AuthorizationServiceHttp.
Controller Usage with Attribute
Protect your endpoints using the AuthZenAuthorize attribute:
using AuthZen.AspNetCore.Filters;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("api/[controller]")]
public class TemplateController : ControllerBase
{
private readonly TemplateService _templateService;
public TemplateController(TemplateService templateService)
{
_templateService = templateService;
}
[HttpGet]
[AuthZenAuthorize("view")]
public async Task<IActionResult> GetAll()
{
var templates = await _templateService.GetAllAsync();
return Ok(templates);
}
[HttpPost]
[AuthZenAuthorize("create")]
public async Task<IActionResult> CreateTemplate([FromBody] TemplateDto dto)
{
await _templateService.CreateAsync(dto);
return Ok();
}
}
Notes:
"view" and "create" represent the relation to check.
By default, the userId is taken from the logged-in user (HttpContext.User).
Optional UserId Override
You can override the userId if needed:
[AuthZenAuthorize("view", userId: "123")]
If omitted, AuthZen uses the current logged-in user automatically.
Configuration via appsettings.json
Store the AuthZen service URL in your configuration:
{
"AuthZen": {
"FullUrl": "https://auth-service.local/api/access/check"
}
}
And register it in Program.cs:
builder.Services.AddAuthZenAuthorization(options =>
{
options.FullUrl = builder.Configuration["AuthZen:FullUrl"];
});
Notes:
FullUrl should point to your central AuthZen authorization service.
The library automatically handles DI for AuthorizationServiceHttp.
Example Microservice Flow
Microservice receives HTTP request.
AuthZenAuthorizeAttribute triggers authorization check.
AuthorizationServiceHttp sends request to central AuthZen service.
AuthZen service responds true or false.
Attribute either allows execution or returns 403 Forbidden.
Quick Start Microservice Example
Minimal microservice setup using AuthZen.AspNetCore:
Microservice/
│
├─ Program.cs
├─ appsettings.json
├─ Controllers/
│ └─ TemplateController.cs
├─ Services/
│ └─ TemplateService.cs
└─ Models/
└─ TemplateDto.cs
Program.cs
using AuthZen.AspNetCore.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddAuthZenAuthorization(options =>
{
options.FullUrl = "https://auth-service.local/api/access/check";
});
builder.Services.AddScoped<TemplateService>();
var app = builder.Build();
app.MapControllers();
app.Run();
TemplateController.cs
using AuthZen.AspNetCore.Filters;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("api/[controller]")]
public class TemplateController : ControllerBase
{
private readonly TemplateService _templateService;
public TemplateController(TemplateService templateService)
{
_templateService = templateService;
}
[HttpGet]
[AuthZenAuthorize("view")]
public async Task<IActionResult> GetAll()
{
var templates = await _templateService.GetAllAsync();
return Ok(templates);
}
}
TemplateService.cs
public class TemplateService
{
public Task<List<TemplateDto>> GetAllAsync()
{
// Dummy data for testing
return Task.FromResult(new List<TemplateDto>
{
new TemplateDto { Id = "1", Name = "Sample Template" }
});
}
}
TemplateDto.cs
public class TemplateDto
{
public string Id { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net9.0
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.3.9)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.9)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- System.Net.Http.Json (>= 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 |
|---|---|---|
| 2026.2.14.91926 | 98 | 2/14/2026 |
| 2026.2.14.91603 | 85 | 2/14/2026 |
| 2026.2.13.220710 | 97 | 2/13/2026 |
| 2026.2.13.215350 | 87 | 2/13/2026 |
| 1.0.0 | 88 | 2/13/2026 |
Initial release of AuthZen.AspNetCore library with HTTP client, authorization attribute, DI extension, and options support.