Common.API.Extensions.Lib
1.0.16
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 Common.API.Extensions.Lib --version 1.0.16
NuGet\Install-Package Common.API.Extensions.Lib -Version 1.0.16
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="Common.API.Extensions.Lib" Version="1.0.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Common.API.Extensions.Lib" Version="1.0.16" />
<PackageReference Include="Common.API.Extensions.Lib" />
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 1.0.16
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Common.API.Extensions.Lib, 1.0.16"
#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@1.0.16
#: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=1.0.16
#tool nuget:?package=Common.API.Extensions.Lib&version=1.0.16
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
│ ├── AccessTokenValidationMiddleware.cs
│ ├── OpenIdConnectConfiguration.cs
│ ├── TokenValidationService.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<AntiXssMiddleware>();
Token Validation
services.AddSingleton<ITokenService, TokenService>();
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 | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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.
-
net8.0
- Common.Infrastructure.Lib (>= 1.0.55)
- HtmlSanitizer (>= 8.2.871-beta)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.10)
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.10)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.1.2)
- System.Configuration.ConfigurationManager (>= 9.0.0-rc.2.24473.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 |
|---|---|---|
| 2.2.3 | 88 | 1/2/2026 |
| 2.2.2 | 288 | 12/24/2025 |
| 2.2.1 | 168 | 12/24/2025 |
| 2.2.0 | 756 | 11/11/2025 |
| 1.0.19 | 251 | 6/9/2025 |
| 1.0.18 | 144 | 6/3/2025 |
| 1.0.17 | 1,777 | 3/25/2025 |
| 1.0.16 | 251 | 3/10/2025 |
| 1.0.15 | 159 | 3/10/2025 |
| 1.0.14 | 168 | 3/10/2025 |
| 1.0.13 | 431 | 12/8/2024 |
| 1.0.12 | 97 | 12/7/2024 |
| 1.0.11 | 680 | 11/26/2024 |
| 1.0.10 | 98 | 11/26/2024 |
| 1.0.9 | 175 | 11/8/2024 |
| 1.0.8 | 307 | 10/29/2024 |
| 1.0.7 | 121 | 10/28/2024 |
| 1.0.6 | 112 | 10/28/2024 |
| 1.0.5 | 145 | 10/25/2024 |
| 1.0.3 | 280 | 10/23/2024 |
| 1.0.2 | 341 | 10/21/2024 |
| 1.0.1 | 157 | 10/21/2024 |
| 1.0.0 | 158 | 10/15/2024 |