RuoVea.ExFilter 8.0.1.5

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

RuoVea.ExFilter

介绍

注入 进行全局的异常日志收集、执行操作日志、参数验证、对资源型信息进行过滤、对结果进行统一、接口安全校验、签名验证 MD5 ( appKey + signKey + timeStamp + data );支持简体中文、繁体中文、粤语、日语、法语、英语.

1.快速入门

通过Nuget安装组件

Install-Package RuoVea.ExFilter

2、使用示例

注入 进行全局的异常日志收集、执行操作日志、参数验证

builder.Services.ExceptionSetup();// 注入 全局错误日志

builder.Services.ExceptionSetup(ExceptionLog actionOptions);// 注入 全局错误日志

builder.Services.ExceptionSetup(builder.Configuration.GetSection("AopOption:ExceptionLog"));// 注入 全局错误日志

builder.Services.RequestActionSetup();// 注入 请求日志拦截 [执行操作日志、参数验证 ]

builder.Services.RequestActionSetup(RequestLog actionOptions);// 注入 请求日志拦截 [执行操作日志、参数验证 ]

builder.Services.RequestActionSetup(builder.Configuration.GetSection("AopOption:RequestLog"));// 注入 请求日志拦截 [执行操作日志、参数验证 ]

builder.Services.ResourceSetup();//对资源型信息进行过滤

builder.Services.ResultSetup();//对结果进行统一

builder.Services.ApISafeSetup(AppSign actionOptions);//接口安全校验

builder.Services.ApISafeSetup(builder.Configuration.GetSection("AopOption:AppSign"));//接口安全校验

builder.Services.ApISignSetup(AppSign actionOptions);//签名验证 ( appKey + signKey + timeStamp + data );

builder.Services.ApISignSetup(builder.Configuration.GetSection("AopOption:AppSign"));//签名验证 ( appKey + signKey + timeStamp + data );

builder.Services.AddUiFilesZipSetup();//将前端UI压缩文件进行解压

app.UseVirtualPathMiddle();//虚拟路径

前端
"appKey": appKey,
"timeStamp": (Math.floor(Date.now() / 1000) + 1000),

3、继承重写

3.1、IRestfulFilterLog 方法

    /// <summary>
    /// 成功返回值
    /// </summary>
    /// <param name="context"></param>
    /// <param name="data"></param>
    /// <returns>ActionExecutionDelegate</returns>
    IActionResult OnSucceeded(ActionExecutedContext context, object data);
    /// <summary>
    /// 验证失败返回值
    /// </summary>
    /// <param name="context"></param>
    /// <param name="metadata"></param>
    /// <returns></returns>
    IActionResult OnValidateFailed(ActionExecutingContext context, ValidationMetadata metadata);
 
    /// <summary>
    /// 异常日志
    /// </summary>
    /// <param name="exception"></param>
    void ExceptionLog( ExceptionVo exception);
    /// <summary>
    /// 操作日志
    /// </summary>
    /// <param name="operation"></param>
    void OperationLog(OperationVo operation);

3.2、预实现 RestfulFilterLog

    /// <summary>
    /// 操作日志
    /// </summary>
    /// <param name="operation"></param>
    virtual void OperationLog(OperationVo operation)
    
    /// <summary>
    /// 异常日志
    /// </summary>
    /// <param name="exception"></param>
    virtual void ExceptionLog(ExceptionVo exception)

4、Non**特性相关

不进行接口安全校验 → NonAplSafeAttribute

不签名验证 → NonAplSignAttribute

不进行全局的异常日志收集 → NonExceptionAttribute

不对资源型信息进行过滤 → NonResourceAttribute

不对结果进行统一 → NonRestfulResultAttribute

5、相关配置文件

  /* 全局的异常日志配置 */
  "ExceptionLog": {
    "Enabled": true,
    "LogToFile": false,
    "LogMore": false
  },

   /* 请求日志拦截配置 */
  "RequestLog": {
    "Enabled": true,
    "LogToFile": false, //记录到文件
    "LogMore": false, //记录更多内容 如写入数据库 需继承重写 IRestfulFilterLog
    "IgnoreApis": ""
  },

  /*接口安全校验*/
  "ApISafe": {
    "AppKeys": "",//多个appKey用逗号分开
    "AppKeyName": "appKey",
    "TimeStampName": "timeStamp",
    "ExpiresMinute": 2, //单位(分钟) 
  }

  /*签名验证*/
  "AppSign": {
    "AppKeys": "",//多个appKey用逗号分开
    "AppKeyName": "appKey",
    "TimeStampName": "timeStamp",
    "ExpiresMinute": 2, //单位(分钟) 

    "SignKey": "", //签名key 
    "SignatureName": "signature", //签名
    "IgnoreApi": "" //签名验证忽略api列表
  }


 /* 整合配置 */
  "AopOption": {
    "RequestLog": {
      "Enabled": true,
      "LogToFile": false, //记录到文件
      "LogMore": false, //记录更多内容 如写入数据库 需继承重写 IRestfulFilterLog
      "IgnoreApis": ""
    },
    "ExceptionLog": {
      "Enabled": true,
      "LogToFile": false,
      "LogMore": false
    },
    "AppSign": {
      "AppKeys": "",//多个appKey用逗号分开
      "AppKeyName": "appKey",
      "TimeStampName": "timeStamp",
      "ExpiresMinute": 2, //单位(分钟)  

      "SignKey": "", //签名key 
      "SignatureName": "signature", //签名
      "IgnoreApi": "" //签名验证忽略api列表
    }
  },

  "VirtualPath":""//虚拟路径

6、Http 拓展类

/// <summary>
/// 设置规范化文档自动登录
/// </summary>
/// <param name="httpContext">HttpContext</param>
/// <param name="accessToken">accessToken</param>
static void SigninToSwagger(this HttpContext httpContext, string accessToken)

/// <summary>
/// 设置规范化文档退出登录
/// </summary>
/// <param name="httpContext">HttpContext</param>
static void SignoutToSwagger(this HttpContext httpContext)

/// <summary>
/// 获取完整请求地址
/// </summary>
/// <param name="request">HttpRequest</param>
/// <returns>完整请求地址</returns>
static string GetRequestUrlAddress(this HttpRequest request)

/// <summary>
/// 获取站点 (http|s)://Host
/// </summary>
/// <param name="request">HttpRequest</param>
/// <returns>完整请求地址</returns>
static string GetRequestHost(this HttpRequest request)

/// <summary>
/// 获取站点 (http|s)://Host:端口
/// </summary>
/// <param name="request">HttpRequest</param>
/// <returns>完整请求地址</returns>
static string GetRequestHostPort(this HttpRequest request)

/// <summary>
/// 获取来源地址
/// </summary>
/// <param name="request">HttpRequest</param>
/// <param name="refererHeaderKey">刷新的key值</param>
/// <returns>来源地址</returns>
static string GetRefererUrl(this HttpRequest request, string refererHeaderKey = "Referer")

/// <summary>
/// 获得浏览器 Chrome、Safari、Firefox、Edg、Opera、IE
/// </summary>
/// <returns>字符串数组</returns>
static string GetBrowser(this HttpContext httpContext)

/// <summary>
/// 请求UserAgent信息
/// </summary>
static string UserAgent(this HttpContext httpContext)

/// <summary>
/// 获取 User-Agent 所有信息
/// </summary>
static ClientInfo GetDefault(this HttpContext httpContext)

/// <summary>
/// 得到操作系统版本
/// </summary>
/// <returns></returns>
static string GetOSVersion(this HttpContext httpContext)

/// <summary>
/// UserAgent信息
/// </summary>
/// <param name="httpContext"></param>
/// <returns>手机型号,操作系统(版本),浏览器(版本)</returns>
static (string PhoneModel, string OS,string Browser) UserAgentInfo(this HttpContext httpContext)

/// <summary>
/// 远程路径Encode处理,会保证开头是/,结尾也是/
/// </summary>
/// <param name="remotePath"></param>
/// <returns></returns>
static string EncodeRemotePath(this string remotePath)

/// <summary>
/// 获取本机 IPv4地址
/// </summary>
/// <param name="context">HttpContext</param>
/// <returns>IPv4地址</returns>
static string GetLocalIpAddressToIPv4(this HttpContext context) 

/// <summary>
/// 获取本机 IPv6地址
/// </summary>
/// <param name="context">HttpContext</param>
/// <returns>IPv6地址</returns>
static string GetLocalIpAddressToIPv6(this HttpContext context) 

/// <summary>
/// 获取远程 IPv6地址
/// </summary>
/// <param name="context">HttpContext</param>
/// <returns>远程 IPv6地址</returns>
static string GetRemoteIpAddressToIPv6(this HttpContext context) 

/// <summary>
/// 获得IP地址 业务使用
/// </summary>
/// <returns>字符串数组</returns>
static string GetIp(this HttpContext context) 

/// <summary>
/// 得到局域网IP地址
/// </summary>
/// <returns></returns>
static string GetLanIp(this HttpContext context) 

7、提供注入的服务

    /// <summary>
    /// 注入 全局异常处理 [进行全局的异常日志收集]
    /// </summary>
    /// <param name="services"></param>
    static IServiceCollection ExceptionSetup(this IServiceCollection services)

    /// <summary>
    /// 注入 全局异常处理 [进行全局的异常日志收集]
    /// </summary>
    /// <param name="services"></param>
    /// <param name="actionOptions"></param>
    /// <returns></returns>
    static IServiceCollection ExceptionSetup(this IServiceCollection services, Action<ExceptionLog> actionOptions)

    /// <summary>
    /// 注入 全局异常处理 [进行全局的异常日志收集]
    /// </summary>
    /// <param name="services"></param>
    /// <param name="config"></param>
    static IServiceCollection ExceptionSetup(this IServiceCollection services, IConfiguration config)

    /// <summary>
    /// 注入 请求日志拦截 [执行操作日志、参数验证,权限控制 ]
    /// </summary>
    static IServiceCollection RequestActionSetup(this IServiceCollection services)

    /// <summary>
    /// 注入 请求日志拦截 [执行操作日志、参数验证,权限控制 ]
    /// </summary>
    /// <param name="services"></param>
    /// <param name="actionOptions"></param>
    static IServiceCollection RequestActionSetup(this IServiceCollection services, Action<RequestLog> actionOptions)

    /// <summary>
    /// 注入 请求日志拦截 [执行操作日志、参数验证,权限控制 ]
    /// </summary>
    /// <param name="services"></param>
    /// <param name="config"></param>
    static IServiceCollection RequestActionSetup(this IServiceCollection services, IConfiguration config)

    /// <summary>
    /// 注入 对资源型信息进行过滤。常用于防盗链/资源缓存
    /// </summary>
    static IServiceCollection ResourceSetup(this IServiceCollection services)

    /// <summary>
    /// 结果格式化处理
    /// </summary>
    /// <param name="services"></param>
    static IServiceCollection ResultSetup(this IServiceCollection services)

    /// <summary>
    /// 接口appkey和时间戳校验
    /// </summary>
    /// <param name="services"></param>
    /// <param name="actionOptions"></param>
    /// <returns></returns>
    static IServiceCollection ApISafeSetup(this IServiceCollection services, Action<ApISafe> actionOptions)

    /// <summary>
    /// 接口appkey和时间戳校验
    /// </summary>
    /// <param name="services"></param>
    /// <param name="config"></param>
    /// <returns></returns>
    static IServiceCollection ApISafeSetup(this IServiceCollection services, IConfiguration config)
    
    /// <summary>
    /// 签名验证 ( appKey + signKey + timeStamp + data );
    /// </summary>
    /// <param name="services"></param>
    /// <param name="actionOptions"></param>
    /// <returns></returns>
    static IServiceCollection ApISignSetup(this IServiceCollection services, Action<AppSign> actionOptions)
   
    /// <summary>
    /// 签名验证 ( appKey + signKey + timeStamp + data );
    /// </summary>
    /// <param name="services"></param>
    /// <param name="config"></param>
    /// <returns></returns>
    static IServiceCollection ApISignSetup(this IServiceCollection services, IConfiguration config)
    
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TFilterType"></typeparam>
    /// <param name="services"></param>
    /// <returns></returns>
    static IServiceCollection AddRestfulSetup<TFilterType>(this IServiceCollection services) where TFilterType : IRestfulFilterLog
    
    /// <summary>
    /// 弃用原始模型验证
    /// </summary>
    /// <param name="services"></param>
    /// <param name="configure">options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true;</param>
    /// <returns></returns>
    static IMvcBuilder AddValidateSetup(this IServiceCollection services, Action<MvcOptions> configure=null)
    
    /// <summary>
    /// 规范化模型校验
    /// </summary>
    /// <param name="services"></param>
    /// <param name="configureOptions">弃用原始模型验证:options.SuppressModelStateInvalidFilter=true;</param>
    /// <returns></returns>
    static IServiceCollection AddRestfulModelsSetup(this IServiceCollection services, Action<ApiBehaviorOptions> configureOptions = null)
    
    /// <summary>
    /// 将前端UI压缩文件进行解压
    /// </summary>
    /// <param name="services"></param>
    /// <param name="_env"></param>
    /// <exception cref="ArgumentNullException"></exception>
    static void AddUiFilesZipSetup(this IServiceCollection services, IWebHostEnvironment _env)
    
    /// <summary>
    /// 使用虚拟路径
    /// </summary>
    /// <param name="app"></param>
    /// <returns></returns>
    static WebApplication UseVirtualPathMiddle(this WebApplication app)
    
    /// <summary>
    /// 使用虚拟路径
    /// </summary>
    /// <param name="app"></param>
    /// <param name="virtualPath"></param>
    /// <returns></returns>
    static WebApplication UseVirtualPathMiddle(this WebApplication app, string virtualPath)
    
        
Product 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.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on RuoVea.ExFilter:

Package Downloads
RuoVea.OmiConfig

参数配置

RuoVea.OmiApi.UserRoleMenu

用户、角色、菜单管理 API

RuoVea.OmiLog

字典管理

RuoVea.OmiDict

字典管理

RuoVea.OmiApi.SystemApp

用户、角色、菜单、机构、职位、权限管理 API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.1.5 309 4/23/2025
8.0.1.4 741 11/21/2024
8.0.1.3 147 11/1/2024
8.0.1.2 119 9/22/2024
8.0.1.1 131 9/18/2024
8.0.1 127 8/28/2024
8.0.0 106 7/23/2024
7.0.1.5 321 4/23/2025
7.0.1.4 857 11/21/2024
7.0.1.3 112 11/1/2024
7.0.1.2 131 9/22/2024
7.0.1.1 124 9/18/2024
7.0.1 117 8/28/2024
7.0.0 102 7/23/2024
6.0.19.5 374 4/23/2025
6.0.19.4 2,533 11/21/2024
6.0.19.3 964 11/1/2024
6.0.19.2 1,241 9/22/2024
6.0.19.1 151 9/18/2024
6.0.19 120 8/28/2024
6.0.18.13 179 8/25/2024
6.0.18.12 169 4/15/2024
6.0.18.11 160 4/14/2024
6.0.18.10 185 3/13/2024
6.0.18.9 201 3/13/2024
6.0.18.8 188 3/11/2024
6.0.18.7 235 2/28/2024
6.0.18.6 205 2/27/2024
6.0.18.5 279 1/29/2024
6.0.18.4 281 1/27/2024
6.0.18.3 247 1/26/2024
6.0.18.2 367 12/28/2023
6.0.18.1 327 12/1/2023
6.0.18 344 9/27/2023
6.0.17 328 9/16/2023
6.0.16 457 3/26/2023
6.0.15 439 3/26/2023
6.0.13 467 3/11/2023
6.0.12 517 12/23/2022
6.0.11 455 12/23/2022
6.0.10 594 10/8/2022
6.0.9 657 9/16/2022
6.0.8 637 8/18/2022
6.0.7 647 6/10/2022
6.0.6 707 3/15/2022
6.0.5 689 3/14/2022
6.0.4 671 2/18/2022
6.0.3 617 2/18/2022
6.0.2 662 2/17/2022
6.0.1 690 2/15/2022
6.0.0 700 2/11/2022
5.0.0.4 159 4/23/2025
5.0.0.3 126 11/21/2024
5.0.0.2 137 11/1/2024
5.0.0.1 122 9/22/2024
5.0.0 124 9/18/2024