Common.API.Extensions.Lib
2.5.1
dotnet add package Common.API.Extensions.Lib --version 2.5.1
NuGet\Install-Package Common.API.Extensions.Lib -Version 2.5.1
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.
For projects that support PackageReference, copy this XML node into the project file to reference the package.
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 Common.API.Extensions.Lib --version 2.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Common.API.Extensions.Lib, 2.5.1"
#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 Common.API.Extensions.Lib@2.5.1
#: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=Common.API.Extensions.Lib&version=2.5.1
#tool nuget:?package=Common.API.Extensions.Lib&version=2.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Common.API.Extensions for .NET 8
This project provides a set of extensions for .NET 8 applications, covering authentication, logging, security, and validation.
Features
- Custom Authorization: Implements role-based access control with custom attributes.
- Logging: Provides Serilog-based logging extensions.
- Security: Includes middleware for XSS protection.
- Utilities: Provides reusable token management services.
- Validation: Implements custom DTO validation attributes.
Project Structure
Common.API.Extensions
├── CustomAuthorization
│ ├── Model
│ │ ├── Menu.cs
│ │ ├── Permission.cs
│ │ ├── SubMenu.cs
│ │ ├── UserAccessDetails.cs
│ ├── CustomAuthorizeAttribute.cs
├── Logging
│ ├── ConfigurationExtensions.cs
│ ├── Constants.cs
│ ├── RequestLoggingMiddleware.cs
├── Sanitation
│ ├── AntiXssMiddleware.cs
│ ├── ErrorResponse.cs
│ ├── XssSettings.cs
├── Utils
│ ├── TokenService.cs
├── Validation
│ ├── CustomDtoValidations
│ │ ├── AccomodationKind
│ │ ├── ContactKind
│ │ ├── EventKind
│ │ ├── RoomType
│ │ ├── DateGreaterThanAttribute.cs
├── LICENSE.txt
├── README.md
Installation
Install required NuGet packages:
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer dotnet add package Serilog.AspNetCore dotnet add package Serilog.Settings.Configuration dotnet add package Serilog.Sinks.Console
Usage
Logging Configuration
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Serilog.Formatting.Json;
public static class LoggingExtensions
{
public static IHostBuilder UseUniversalLogging(this IHostBuilder hostBuilder)
{
hostBuilder.UseSerilog((context, services, loggerConfiguration) =>
{
loggerConfiguration
.ReadFrom.Configuration(context.Configuration)
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(new JsonFormatter()) // Writes logs to console
.WriteTo.Console(new JsonFormatter(), standardErrorFromLevel: LogEventLevel.Verbose); // Writes logs to stdout
});
return hostBuilder;
}
}
Authorization
[CustomAuthorize("Admin")]
public class AdminController : ControllerBase
{
// Controller logic here
}
XSS Protection Middleware
app.UseMiddleware();
Token Validation
services.AddSingleton();
Deployment Notes
- Ensure your authentication and logging configurations are properly set in
appsettings.json. - Supports Kubernetes logging with JSON formatting for compatibility with log aggregators like Fluentd and Loki.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch - Commit changes:
git commit -m "Added new feature" - Push and create a PR.
| 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
- HtmlSanitizer (>= 9.0.892)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.10)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 9.0.10)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Routing.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.2)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.1.2)
- Microsoft.OpenApi (>= 1.6.14)
- Newtonsoft.Json (>= 13.0.3)
- prometheus-net.AspNetCore (>= 8.2.1)
- StackExchange.Redis (>= 2.8.37)
- Swashbuckle.AspNetCore (>= 6.4.0)
- System.Configuration.ConfigurationManager (>= 9.0.11)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Common.API.Extensions.Lib:
| Package | Downloads |
|---|---|
|
Common.Infrastructure.Lib
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.5.1 | 207 | 5/6/2026 | |
| 2.5.0 | 249 | 4/1/2026 | |
| 2.4.4 | 436 | 3/11/2026 | |
| 2.4.3 | 326 | 3/3/2026 | |
| 2.4.2 | 451 | 2/20/2026 | |
| 2.4.1 | 153 | 2/20/2026 | |
| 2.4.0 | 152 | 2/20/2026 | |
| 2.3.0 | 423 | 2/11/2026 | |
| 2.2.6 | 159 | 2/9/2026 | |
| 2.2.5 | 240 | 2/4/2026 | |
| 2.2.4 | 159 | 1/28/2026 | |
| 2.2.3 | 188 | 1/2/2026 | |
| 2.2.2 | 555 | 12/24/2025 | |
| 2.2.1 | 243 | 12/24/2025 | |
| 2.2.0 | 839 | 11/11/2025 | |
| 1.0.19 | 324 | 6/9/2025 | |
| 1.0.18 | 201 | 6/3/2025 | |
| 1.0.17 | 1,855 | 3/25/2025 | |
| 1.0.16 | 338 | 3/10/2025 | |
| 1.0.15 | 234 | 3/10/2025 |
Loading failed