Tolitech.Presentation 1.0.0-preview.4

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

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 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.

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