Serve Media and App_Plugins using WebRootFileProvider (and allow changing the physical media path) (#11783)

* Allow changing UmbracoMediaPath to an absolute path. Also ensure Imagesharp are handing requests outside of the wwwroot folder.

* Let UmbracoMediaUrl fallback to UmbracoMediaPath when empty

* Add FileSystemFileProvider to expose an IFileSystem as IFileProvider

* Replace IUmbracoMediaFileProvider with IFileProviderFactory implementation

* Fix issue resolving relative paths when media URL has changed

* Remove FileSystemFileProvider and require explicitly implementing IFileProviderFactory

* Update tests (UnauthorizedAccessException isn't thrown anymore for rooted files)

* Update test to use UmbracoMediaUrl

* Add UmbracoMediaPhysicalRootPath global setting

* Remove MediaFileManagerImageProvider and use composited file providers

* Move CreateFileProvider to IFileSystem extension method

* Add rooted path tests

Co-authored-by: Ronald Barendse <ronald@barend.se>
This commit is contained in:
Bjarke Berg
2022-01-06 13:35:24 +01:00
committed by GitHub
parent 84fea8f953
commit 642c216f94
24 changed files with 233 additions and 96 deletions

View File

@@ -31,21 +31,19 @@ namespace Umbraco.Cms.Core.Configuration.Models
internal const bool StaticSanitizeTinyMce = false;
/// <summary>
/// Gets or sets a value for the reserved URLs.
/// It must end with a comma
/// Gets or sets a value for the reserved URLs (must end with a comma).
/// </summary>
[DefaultValue(StaticReservedUrls)]
public string ReservedUrls { get; set; } = StaticReservedUrls;
/// <summary>
/// Gets or sets a value for the reserved paths.
/// It must end with a comma
/// Gets or sets a value for the reserved paths (must end with a comma).
/// </summary>
[DefaultValue(StaticReservedPaths)]
public string ReservedPaths { get; set; } = StaticReservedPaths;
/// <summary>
/// Gets or sets a value for the timeout
/// Gets or sets a value for the back-office login timeout.
/// </summary>
[DefaultValue(StaticTimeOut)]
public TimeSpan TimeOut { get; set; } = TimeSpan.Parse(StaticTimeOut);
@@ -104,11 +102,19 @@ namespace Umbraco.Cms.Core.Configuration.Models
public string UmbracoScriptsPath { get; set; } = StaticUmbracoScriptsPath;
/// <summary>
/// Gets or sets a value for the Umbraco media path.
/// Gets or sets a value for the Umbraco media request path.
/// </summary>
[DefaultValue(StaticUmbracoMediaPath)]
public string UmbracoMediaPath { get; set; } = StaticUmbracoMediaPath;
/// <summary>
/// Gets or sets a value for the physical Umbraco media root path (falls back to <see cref="UmbracoMediaPath" /> when empty).
/// </summary>
/// <remarks>
/// If the value is a virtual path, it's resolved relative to the webroot.
/// </remarks>
public string UmbracoMediaPhysicalRootPath { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to install the database when it is missing.
/// </summary>
@@ -131,6 +137,9 @@ namespace Umbraco.Cms.Core.Configuration.Models
/// </summary>
public string MainDomLock { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the telemetry ID.
/// </summary>
public string Id { get; set; } = string.Empty;
/// <summary>
@@ -164,19 +173,19 @@ namespace Umbraco.Cms.Core.Configuration.Models
/// </summary>
public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation);
/// Gets a value indicating whether TinyMCE scripting sanitization should be applied
/// <summary>
/// Gets a value indicating whether TinyMCE scripting sanitization should be applied.
/// </summary>
[DefaultValue(StaticSanitizeTinyMce)]
public bool SanitizeTinyMce => StaticSanitizeTinyMce;
/// <summary>
/// An int value representing the time in milliseconds to lock the database for a write operation
/// Gets a value representing the time in milliseconds to lock the database for a write operation.
/// </summary>
/// <remarks>
/// The default value is 5000 milliseconds
/// The default value is 5000 milliseconds.
/// </remarks>
/// <value>The timeout in milliseconds.</value>
[DefaultValue(StaticSqlWriteLockTimeOut)]
public TimeSpan SqlWriteLockTimeOut { get; } = TimeSpan.Parse(StaticSqlWriteLockTimeOut);
}
}
}