IpShieldMiddleware 1.0.0
dotnet add package IpShieldMiddleware --version 1.0.0
NuGet\Install-Package IpShieldMiddleware -Version 1.0.0
<PackageReference Include="IpShieldMiddleware" Version="1.0.0" />
<PackageVersion Include="IpShieldMiddleware" Version="1.0.0" />
<PackageReference Include="IpShieldMiddleware" />
paket add IpShieldMiddleware --version 1.0.0
#r "nuget: IpShieldMiddleware, 1.0.0"
#:package IpShieldMiddleware@1.0.0
#addin nuget:?package=IpShieldMiddleware&version=1.0.0
#tool nuget:?package=IpShieldMiddleware&version=1.0.0
IpShieldMiddleware
IpShieldMiddleware
is a lightweight ASP.NET Core middleware for IP-based request filtering. It allows whitelisting or blacklisting specific IP addresses with customizable error messages and logging.
This middleware intercepts incoming HTTP requests and performs IP filtering based on the configured whitelist and blacklist IP's.
-Requests from whitelisted IPs are allowed.
-Requests from blacklisted IPs are blocked, returning a response of 403 (Forbidden) with the default message in case no custom message was provided.
🔧 Features
- ✅ Whitelist specific IP addresses
- 🚫 Blacklist unwanted IP addresses
- ✍️ Optional custom error messages with IP placeholder (
{IP}
) for both response and logging (if not provided a default message will be used) - 📝 Built-in logging support
- 📦 Plug-and-play for ASP.NET Core projects
📦 Installation
dotnet add package IpShieldMiddleware
🚀 Getting Started
builder.Services.Configure<IpShieldOptions>(options =>
{
options.WhitelistedIps = new List<string> { "127.0.0.1", "::1" };
options.BlacklistedIps = new List<string> { "192.168.1.100" };
options.CustomLogMessage = "This is a custom log message for ip: {IP}";
options.CustomErrorMessage = "This is a custom response message for ip: {IP}";
});
var app = builder.Build();
app.UseIpShield();
or if you want to keep configs in appsettings
"IpShieldOptions": {
"BlacklistedIps": [ "192.168.1.10" ],
"WhitelistedIps": [ "127.0.0.1", "localhost", "::1" ],
"CustomLogMessage": "This is a custom log message for ip: {IP}",
"CustomErrorMessage": "This is a custom response message for ip: {IP}"
}
then in your program.cs
builder.Services.Configure<IpShieldOptions>(builder.Configuration.GetSection("IpShieldOptions"));
var app = builder.Build();
app.UseIpShield();
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. |
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Options (>= 9.0.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 | 158 | 5/25/2025 |