DNMH.Security.IpRestriction
9.0.0
dotnet add package DNMH.Security.IpRestriction --version 9.0.0
NuGet\Install-Package DNMH.Security.IpRestriction -Version 9.0.0
<PackageReference Include="DNMH.Security.IpRestriction" Version="9.0.0" />
<PackageVersion Include="DNMH.Security.IpRestriction" Version="9.0.0" />
<PackageReference Include="DNMH.Security.IpRestriction" />
paket add DNMH.Security.IpRestriction --version 9.0.0
#r "nuget: DNMH.Security.IpRestriction, 9.0.0"
#addin nuget:?package=DNMH.Security.IpRestriction&version=9.0.0
#tool nuget:?package=DNMH.Security.IpRestriction&version=9.0.0
DNMH.Security.IpRestriction
Overview
DNMH.Security.IpRestriction
is a .NET library that provides IP restriction middleware for your web applications. It allows you to restrict access to your application based on a configurable list of allowed or denied IP addresses.
Installation
You can install this library using NuGet. Simply run the following command:
dotnet add package DNMH.Security.IpRestriction
This will add IP restriction functionality to your .NET application.
Usage
To use this library, follow these steps:
- In your
Startup.cs
file (orProgram.cs
for minimal APIs), configure the IP restriction middleware:
builder.Services.AddIpRestriction(options =>
{
options.Global.Deny.Add("192.168.1.1");
options.Profiles["profileKey"].Allow.Add("10.0.0.1");
});
And then adds the middleware after the web application is built:
app.UseIpRestriction();
- Rely on the Globally configured restrictions that are applied to all requests, or use the
[IpRestricted("profileKey")]
attribute to apply IP restrictions to specific controllers or actions:
[Route("api/[controller]")]
[ApiController]
public class MyController : ControllerBase
{
[HttpGet]
[IpRestricted("myProfile")]
public IActionResult Get()
{
return Ok("Access granted!");
}
}
License
This library is licensed under the MIT License.
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 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. |
-
net8.0
- IPNetwork2 (>= 3.1.764)
-
net9.0
- IPNetwork2 (>= 3.1.764)
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 |
---|---|---|
9.0.0 | 132 | 5/5/2025 |