AnointedAutomation.APIMiddlewares 1.0.4

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

AnointedAutomation.APIMiddleware

Overview

The AnointedAutomation.APIMiddleware library is a comprehensive middleware solution for ASP.NET Core applications. It provides tools for security, performance optimization, and API monitoring. Features include IP blacklisting, invalid endpoint tracking, memory management, and API key validation, designed to enhance the reliability and security of your APIs.


Features

Security and Monitoring

  • IP Blacklisting: Automatically blocks malicious IPs after repeated unauthorized attempts.
  • Invalid Endpoint Tracking: Monitors failed attempts to access non-existent endpoints and prevents abuse.
  • API Key Validation: Ensures requests are authorized with the correct API key.
  • Logging: Captures detailed logs of unauthorized access attempts and API interactions.

Performance Optimization

  • Memory Management: Includes garbage collection based on endpoint usage patterns.
  • Idle Endpoint Detection: Identifies idle endpoints to optimize resource usage.

Flexible Middleware

  • Designed to be easily integrated into any ASP.NET Core application.

Installation

Add the library to your ASP.NET Core project and reference the necessary namespaces:

using AnointedAutomation.APIMiddleware;
using AnointedAutomation.APIMiddleware.Filters;
using AnointedAutomation.APIMiddleware.Utility;
using AnointedAutomation.Logging;

Usage

Middleware Components

InvalidEndpointTrackerMiddleware

Tracks attempts to access invalid endpoints and blocks malicious activity.

Example Integration
public void Configure(IApplicationBuilder app)
{
    app.UseMiddleware<InvalidEndpointTrackerMiddleware>();
}

IPBlacklistMiddleware

Blocks requests from IPs flagged for malicious activity.

Example Integration
public void Configure(IApplicationBuilder app)
{
    app.UseMiddleware<IPBlacklistMiddleware>();
}
Get Blocked IPs Log
var logs = IPBlacklistMiddleware.GetLogs();
foreach (var log in logs)
{
    Console.WriteLine(log.message);
}

EndpointAccessMiddleware

Monitors endpoint activity and performs memory cleanup if endpoints remain idle.

Example Integration
public void Configure(IApplicationBuilder app)
{
    app.UseMiddleware<EndpointAccessMiddleware>(TimeSpan.FromMinutes(5), true);
}

Filters

APIKeyAttribute

Validates requests with an API key stored in environment variables.

Example Usage

Apply the attribute to a controller or action:

[APIKey]
[ApiController]
[Route("[controller]")]
public class SecureController : ControllerBase
{
    [HttpGet]
    public IActionResult GetData()
    {
        return Ok("Secure Data Accessed");
    }
}
Environment Variables Required
  • API_KEY: Your API key.
  • API_KEY_NAME: Header name for the API key.

Security Features

IP Blocking

IP addresses are automatically blocked after exceeding the threshold for unauthorized attempts.

IPBlacklist.AddBannedIP("192.168.1.1", "Repeated unauthorized attempts.");

Logging

All middleware components use the logging system provided by AnointedAutomation.Logging.

Add Logs

IPBlacklistMiddleware.AddLog(LogMessage.Warning("Suspicious activity detected."));

Retrieve Logs

var logs = IPBlacklistMiddleware.GetLogs();
foreach (var log in logs)
{
    Console.WriteLine(log.message);
}

Clear Logs

IPBlacklistMiddleware.ClearLogs();

Requirements

  • .NET Core 3.1 or later
  • ASP.NET Core

License

This project is copyrighted © 2024 Anointed Automation, LLC.
All Rights Reserved.


Author

Stewarded by Alexander Fields For inquiries, please contact Anointed Automation. GitHub: https://github.com/AnointedAutomation

Part of the Anointed family of ventures.

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

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.4 635 6/23/2026
1.0.3 163 6/20/2026
1.0.2 300 5/30/2026
1.0.0 627 3/15/2026
0.0.18 210 3/13/2026
0.0.17 123 3/11/2026
0.0.16 516 2/20/2026
0.0.15 181 2/17/2026