Browse Source

解密指定权限

lichunlei 5 months ago
parent
commit
0aeb7b35aa
2 changed files with 15 additions and 0 deletions
  1. 14 0
      Filters/DecryptMiddleware.cs
  2. 1 0
      Model/Base/OptionsSetting.cs

+ 14 - 0
Filters/DecryptMiddleware.cs

@@ -9,7 +9,21 @@ namespace Filters
     {
         public static int Do(HttpContext context)
         {
+            string url = context.Request.Path;
             var request = context.Request;
+            var options = App.OptionsSetting;
+            var paths = options.GatewayDecryptUrl;
+            if(paths.Where(m => !m.Contains("*")).Contains(url))
+            {
+                return 0;
+            }
+            foreach(var path in paths.Where(m => m.Contains("*")))
+            {
+                if(url.StartsWith(path.TrimEnd('*')))
+                {
+                    return 0;
+                }
+            }
             string cipherText = "";
             try
             {

+ 1 - 0
Model/Base/OptionsSetting.cs

@@ -28,6 +28,7 @@ namespace Infrastructure.Model
         public DbConfigs CodeGenDbConfig { get; set; }
         public List<ServiceItem> Services { get; set; }
         public List<string> GatewayFilterUrl { get; set; }
+        public List<string> GatewayDecryptUrl { get; set; }
         public AesItem Aes { get; set; }
     }
     /// <summary>