All Projects → stulzq → UrlFirewall

stulzq / UrlFirewall

Licence: MIT license
UrlFirewall is a lightweight, fast filtering middleware for http request urls.It supports blacklist, whitelist mode.Supports persisting filter rules to any media.You can use it in webapi, gateway, etc.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to UrlFirewall

ByteScout-SDK-SourceCode
ALL source code samples for ByteScout SDKs and Web API API products.
Stars: ✭ 24 (-62.5%)
Mutual labels:  webapi
OnionArchitecture
The onion architecture, introduced by Jeffrey Palermo, overcomes the issues of the layered architecture with great ease. With Onion Architecture, the game-changer is that the Domain Layer (Entities and Validation Rules that are common to the business case ) is at the Core of the Entire Application. This means higher flexibility and lesser coupli…
Stars: ✭ 314 (+390.63%)
Mutual labels:  webapi
aspnet-api-versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,396 (+3643.75%)
Mutual labels:  webapi
NetCoreWithDocker
Tutorial with samples about how to setup .Net Core with Docker
Stars: ✭ 20 (-68.75%)
Mutual labels:  webapi
WebAPI2CLI
Execute ASP.NET Core WebAPI from Command Line
Stars: ✭ 28 (-56.25%)
Mutual labels:  webapi
rabbitmq-labs
The source code for my RabbitMQ tutorials.
Stars: ✭ 45 (-29.69%)
Mutual labels:  webapi
CleanArchitecture
Clean Architecture Solution for .NET 5
Stars: ✭ 18 (-71.87%)
Mutual labels:  webapi
webapiclientgenexamples
Code Examples for using WebApiClientGen
Stars: ✭ 43 (-32.81%)
Mutual labels:  webapi
CSharpCampReCapProject
Kodlama.io | C# Camp | Recap Project | Car Rental System | 2021
Stars: ✭ 17 (-73.44%)
Mutual labels:  webapi
SPA-With-Blazor
Creating a Single Page Application with Razor pages in Blazor using Entity Framework Core database first approach.
Stars: ✭ 27 (-57.81%)
Mutual labels:  webapi
DomainResult
Tiny package for decoupling domain operation results from IActionResult and IResult types of ASP.NET Web API
Stars: ✭ 23 (-64.06%)
Mutual labels:  webapi
WebApiToTypeScript
A tool for code generating TypeScript endpoints for your ASP.NET Web API controllers
Stars: ✭ 26 (-59.37%)
Mutual labels:  webapi
ms-identity-javascript-angular-spa-aspnetcore-webapi
An Angular single-page application that authenticates users with Azure AD and calls a protected ASP.NET Core web API using MSAL Angular
Stars: ✭ 72 (+12.5%)
Mutual labels:  webapi
CrmWebApi
🎉 CRM后台管理系统(后端 WebApi)
Stars: ✭ 13 (-79.69%)
Mutual labels:  webapi
sdk-oauth
Fitbit SDK example application.
Stars: ✭ 66 (+3.13%)
Mutual labels:  webapi
codegenerator
Generate EF6 WebApi with an AngularJS font-end
Stars: ✭ 11 (-82.81%)
Mutual labels:  webapi
FastEndpoints
A light-weight REST API development framework for ASP.Net 6 and newer.
Stars: ✭ 2,386 (+3628.13%)
Mutual labels:  webapi
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+346.88%)
Mutual labels:  webapi
active-directory-javascript-nodejs-webapi-v2
A small Node.js Web API that is protected with Azure AD v2.0 to validate access tokens and accepts authorized calls using Passport.js
Stars: ✭ 76 (+18.75%)
Mutual labels:  webapi
webApi-angularjs
⚓ Definitely simplifies your work with server side & organizes webApi layout to further managing.
Stars: ✭ 15 (-76.56%)
Mutual labels:  webapi

Latest version DUB support-netstandard2.0 support-netcore2.0 build status

UrlFirewall

UrlFirewall is a lightweight, fast filtering middleware for http request urls.It supports blacklist, whitelist mode.Supports persisting filter rules to any media.You can use it in webapi, gateway, etc.

Language

English(Current) | 中文

Get start

1.Install from Nuget to your Asp.Net Core project:

Install-Package UrlFirewall.AspNetCore

2.Configure DI

public void ConfigureServices(IServiceCollection services)
{
    services.AddUrlFirewall(options =>
    {
        options.RuleType = UrlFirewallRuleType.Black;
        options.SetRuleList(Configuration.GetSection("UrlBlackList"));
        options.StatusCode = HttpStatusCode.NotFound;
    });
    services.AddMvc();
    //...
}

3.Configure url firewall middleware.

The order of middleware must be at the top most.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    //Configure url firewall middleware. Top most.
    app.UseUrlFirewall();

    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseMvc();
}

4.Configure rule

In appsettings.json/appsettings.Devolopment.json create a section.

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "UrlBlackList": [
    {
      "Url": "/api/cart/add",
      "Method": "All"
    },
    {
      "Url": "/api/cart/del",
      "Method": "Post"
    },
    {
      "Url": "/api/cart/list",
      "Method": "Get"
    },
    {
      "Url": "/api/product/*",
      "Method": "All"
    }
  ]
}

The url field is the http request path we need to match.It supports wildcard * and ?.The * represents an arbitrary number of arbitrary characters. The ? representative matches any one arbitrary character

5.End

Now,you access /api/cart/add etc.Will be get 404.Enjoy yourself.

Extensibility

If you want to implement validation logic yourself, or You want to verify by getting data from the database, redis etc.You can implement the IUrlFirewallValidator interface.Then you can replace the default implementation with the AddUrlFirewallValidator method.

e.g:

services.AddUrlFirewall(options =>
{
    options.RuleType = UrlFirewallRuleType.Black;
    options.SetRuleList(Configuration.GetSection("UrlBlackList"));
    options.StatusCode = HttpStatusCode.NotFound;
}).AddUrlFirewallValidator<CustomValidator>();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].