From 8f68033ccbf1557b9549e22ab7652b11ffbacc2d Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Thu, 26 Aug 2021 14:35:34 +0200 Subject: [PATCH] allow mapping of secure paths; --- .../CollectionInterceptorHandler.cs | 5 ++- zero.Core/Paths.cs | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/zero.Core/Collections/Interceptors/CollectionInterceptorHandler.cs b/zero.Core/Collections/Interceptors/CollectionInterceptorHandler.cs index c9a98816..f849e48e 100644 --- a/zero.Core/Collections/Interceptors/CollectionInterceptorHandler.cs +++ b/zero.Core/Collections/Interceptors/CollectionInterceptorHandler.cs @@ -51,6 +51,7 @@ namespace zero.Core.Collections where T : ZeroEntity where TParameters : CollectionInterceptor.Parameters { + string typeName = (typeof(T)).Name; Func>> func = default; foreach (InterceptorRegistration registration in ForType(typeof(T))) @@ -65,7 +66,7 @@ namespace zero.Core.Collections func = expression.Compile(); } - Logger.LogDebug("Run interceptor {interceptor} before operation {operation}", registration.Name, instruction.Operation); + Logger.LogDebug("Run interceptor {interceptor} for {type}:{operation}", registration.Name, typeName, instruction.Operation); InterceptorResult result = await func(interceptor); @@ -115,8 +116,6 @@ namespace zero.Core.Collections func = expression.Compile(); } - Logger.LogDebug("Run interceptor {interceptor} after operation {operation}", registration.Name, instruction.Operation); - await func(interceptor); } } diff --git a/zero.Core/Paths.cs b/zero.Core/Paths.cs index 6f0d8e65..5ca06ac1 100644 --- a/zero.Core/Paths.cs +++ b/zero.Core/Paths.cs @@ -13,6 +13,8 @@ namespace zero.Core public string ContentRoot { get; set; } + public string SecureRoot { get; set; } + public string Media { get; set; } protected IWebHostEnvironment Env { get; set; } @@ -42,6 +44,7 @@ namespace zero.Core IsDebug = isDebug; WebRoot = env.WebRootPath; ContentRoot = env.ContentRootPath; + SecureRoot = Path.Combine(ContentRoot, "wwwroot.secure"); Media = Path.Combine(WebRoot, MEDIA_FOLDER); } @@ -63,6 +66,16 @@ namespace zero.Core return Path.Combine(WebRoot, path); } + + /// + /// Map a secure path + /// + public string MapSecure(string path) + { + return Path.Combine(SecureRoot, path); + } + + /// /// Map a path /// @@ -72,6 +85,15 @@ namespace zero.Core } + /// + /// Map a secure path + /// + public string MapSecure(params string[] paths) + { + return Path.Combine(SecureRoot, Path.Combine(paths)); + } + + /// /// Create a directory if it does not exist yet /// @@ -138,6 +160,8 @@ namespace zero.Core string WebRoot { get; set; } + string SecureRoot { get; set; } + string Media { get; set; } /// @@ -150,11 +174,21 @@ namespace zero.Core /// string Map(string path); + /// + /// Map a secure path + /// + string MapSecure(string path); + /// /// Map a path /// string Map(params string[] paths); + /// + /// Map a secure path + /// + string MapSecure(params string[] paths); + /// /// Create a directory if it does not exist yet ///