AB6455 - Stub'ed WebSecurity, cleanup and fix issue with content root vs web root

This commit is contained in:
Bjarke Berg
2020-05-12 20:28:40 +02:00
parent f586883da1
commit cd48adc7af
7 changed files with 28 additions and 26 deletions

View File

@@ -1,7 +1,5 @@
using System.IO;
using Umbraco.Core.Cache;
using Umbraco.Core.Cache;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Serialization;
@@ -10,9 +8,9 @@ namespace Umbraco.Core.Configuration.Grid
{
public class GridConfig : IGridConfig
{
public GridConfig(AppCaches appCaches, IIOHelper ioHelper, IManifestParser manifestParser, IJsonSerializer jsonSerializer, IHostingEnvironment hostingEnvironment)
public GridConfig(AppCaches appCaches, IManifestParser manifestParser, IJsonSerializer jsonSerializer, IHostingEnvironment hostingEnvironment, ILogger logger)
{
EditorsConfig = new GridEditorsConfig(appCaches, ioHelper, manifestParser, jsonSerializer, hostingEnvironment.IsDebugMode);
EditorsConfig = new GridEditorsConfig(appCaches, hostingEnvironment, manifestParser, jsonSerializer, logger);
}
public IGridEditorsConfig EditorsConfig { get; }

View File

@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using Umbraco.Composing;
using Umbraco.Core.Cache;
using Umbraco.Core.IO;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.PropertyEditors;
@@ -14,18 +13,19 @@ namespace Umbraco.Core.Configuration.Grid
internal class GridEditorsConfig : IGridEditorsConfig
{
private readonly AppCaches _appCaches;
private readonly IIOHelper _ioHelper;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IManifestParser _manifestParser;
private readonly bool _isDebug;
private readonly IJsonSerializer _jsonSerializer;
public GridEditorsConfig(AppCaches appCaches, IIOHelper ioHelper, IManifestParser manifestParser,IJsonSerializer jsonSerializer, bool isDebug)
private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger _logger;
public GridEditorsConfig(AppCaches appCaches, IHostingEnvironment hostingEnvironment, IManifestParser manifestParser,IJsonSerializer jsonSerializer, ILogger logger)
{
_appCaches = appCaches;
_ioHelper = ioHelper;
_hostingEnvironment = hostingEnvironment;
_manifestParser = manifestParser;
_jsonSerializer = jsonSerializer;
_isDebug = isDebug;
_logger = logger;
}
public IEnumerable<IGridEditorConfig> Editors
@@ -34,7 +34,7 @@ namespace Umbraco.Core.Configuration.Grid
{
List<IGridEditorConfig> GetResult()
{
var configFolder = new DirectoryInfo(_ioHelper.MapPath(Constants.SystemDirectories.Config));
var configFolder = new DirectoryInfo(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Config));
var editors = new List<IGridEditorConfig>();
var gridConfig = Path.Combine(configFolder.FullName, "grid.editors.config.js");
if (File.Exists(gridConfig))
@@ -47,7 +47,7 @@ namespace Umbraco.Core.Configuration.Grid
}
catch (Exception ex)
{
Current.Logger.Error<GridEditorsConfig>(ex, "Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", sourceString);
_logger.Error<GridEditorsConfig>(ex, "Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", sourceString);
}
}
@@ -61,7 +61,7 @@ namespace Umbraco.Core.Configuration.Grid
}
//cache the result if debugging is disabled
var result = _isDebug
var result = _hostingEnvironment.IsDebugMode
? GetResult()
: _appCaches.RuntimeCache.GetCacheItem<List<IGridEditorConfig>>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10));

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Umbraco.Composing;
using Umbraco.Core;
using Umbraco.Core.Models.Membership;
using Umbraco.Web.Security;
@@ -11,46 +12,46 @@ namespace Umbraco.Web.Common.Security
public class WebSecurity : IWebSecurity
{
public IUser CurrentUser => throw new NotImplementedException();
public IUser CurrentUser => new User(Current.Configs.Global());
public ValidateRequestAttempt AuthorizeRequest(bool throwExceptions = false)
{
throw new NotImplementedException();
return ValidateRequestAttempt.Success;
}
public void ClearCurrentLogin()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
public Attempt<int> GetUserId()
{
throw new NotImplementedException();
return Attempt.Succeed(-1);
}
public bool IsAuthenticated()
{
throw new NotImplementedException();
return true;
}
public double PerformLogin(int userId)
{
throw new NotImplementedException();
return 100;
}
public bool UserHasSectionAccess(string section, IUser user)
{
throw new NotImplementedException();
return true;
}
public bool ValidateCurrentUser()
{
throw new NotImplementedException();
return true;
}
public ValidateRequestAttempt ValidateCurrentUser(bool throwExceptions, bool requiresApproval = true)
{
throw new NotImplementedException();
return ValidateRequestAttempt.Success;
}
}
}

View File

@@ -63,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Config\grid.editors.config.js" />
<Content Include="Config\logviewer.searches.config.js" />
</ItemGroup>

View File

@@ -142,7 +142,6 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Content Include="Config\grid.editors.config.js" />
<Content Include="Config\Lang\cs-CZ.user.xml" />
<Content Include="Config\Lang\da-DK.user.xml" />
<Content Include="Config\Lang\de-DE.user.xml" />

View File

@@ -15,6 +15,9 @@ namespace Umbraco.Web.Website.Controllers
/// <summary>
/// Provides a base class for front-end add-in controllers.
/// </summary>
// TODO: Migrate MergeModelStateToChildAction and MergeParentContextViewData action filters
// [MergeModelStateToChildAction]
// [MergeParentContextViewData]
public abstract class SurfaceController : PluginController
{
private readonly IPublishedUrlProvider _publishedUrlProvider;