Tolitech.Presentation
1.0.0-preview.4
dotnet add package Tolitech.Presentation --version 1.0.0-preview.4
NuGet\Install-Package Tolitech.Presentation -Version 1.0.0-preview.4
<PackageReference Include="Tolitech.Presentation" Version="1.0.0-preview.4" />
<PackageVersion Include="Tolitech.Presentation" Version="1.0.0-preview.4" />
<PackageReference Include="Tolitech.Presentation" />
paket add Tolitech.Presentation --version 1.0.0-preview.4
#r "nuget: Tolitech.Presentation, 1.0.0-preview.4"
#:package Tolitech.Presentation@1.0.0-preview.4
#addin nuget:?package=Tolitech.Presentation&version=1.0.0-preview.4&prerelease
#tool nuget:?package=Tolitech.Presentation&version=1.0.0-preview.4&prerelease
Tolitech.Presentation
Tolitech.Presentation provides interfaces and implementations for endpoint definition and registration, following Clean Architecture principles. It simplifies the configuration of routes and endpoints, promoting organization and clarity in the presentation layer of .NET applications.
Features
- Permission-based Authorization: Easily restrict endpoints by required permissions using attributes and extension methods.
- Route-based API Key Filtering: Secure endpoints by validating API keys per route.
- Endpoint Registration Utilities: Simplify endpoint mapping and organization.
Getting Started
Installation
Add the NuGet package to your project:
dotnet add package Tolitech.Presentation
Usage
1. Permission-based Authorization
Decorate your controllers or endpoints with RequirePermissionAttribute
:
using Tolitech.Presentation.Authorization;
[RequirePermission("Admin")]
public class AdminController : ControllerBase
{
// ...
}
Or use the extension methods for minimal APIs:
app.MapGet("/secure", () => "Secured")
.RequirePermission("User.Read");
RequirePermission
: Requires all specified permissions.RequireAnyPermission
: Requires at least one of the specified permissions.
2. Route-based API Key Filtering
Add the RouteBasedApiKeyEndpointFilter
to your endpoints:
using Tolitech.Presentation.Authorization;
app.MapGet("/test", () => "Test")
.AddEndpointFilter<RouteBasedApiKeyEndpointFilter>();
Configure your API keys in appsettings.json
:
"ApiKeySettings": {
"/test": "your-api-key"
}
Requests must include the X-Api-Key
header with the correct value.
Example
app.MapGet("/admin", () => "Admin area")
.RequirePermission("Admin")
.AddEndpointFilter<RouteBasedApiKeyEndpointFilter>();
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. |
-
net9.0
- Tolitech.Results (>= 1.0.0-preview.5)
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-preview.4 | 511 | 7/22/2025 |
1.0.0-preview.3 | 128 | 7/3/2025 |
1.0.0-preview.2 | 122 | 7/3/2025 |
1.0.0-preview.1 | 137 | 12/10/2024 |