Merge remote-tracking branch 'origin/netcore/dev' into netcore/dev

This commit is contained in:
Bjarke Berg
2020-01-22 11:58:20 +01:00
42 changed files with 230 additions and 126 deletions
+4 -2
View File
@@ -15,6 +15,7 @@ using Umbraco.Core.Strings;
using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web.Composing;
using Umbraco.Web.Models.PublishedContent;
using Umbraco.Web.Routing;
@@ -88,7 +89,7 @@ namespace Umbraco.Tests.TestHelpers
internal PublishedRouter CreatePublishedRouter(IFactory container = null, ContentFinderCollection contentFinders = null)
{
return CreatePublishedRouter(TestObjects.GetUmbracoSettings().WebRouting, container, contentFinders);
return CreatePublishedRouter(TestObjects.GetUmbracoSettings().WebRouting, container ?? Factory, contentFinders);
}
internal static PublishedRouter CreatePublishedRouter(IWebRoutingSection webRoutingSection, IFactory container = null, ContentFinderCollection contentFinders = null)
@@ -99,7 +100,8 @@ namespace Umbraco.Tests.TestHelpers
new TestLastChanceFinder(),
new TestVariationContextAccessor(),
container?.TryGetInstance<ServiceContext>() ?? ServiceContext.CreatePartial(),
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()),
container?.TryGetInstance<IUmbracoSettingsSection>() ?? Current.Factory.GetInstance<IUmbracoSettingsSection>());
}
}
}
@@ -32,6 +32,7 @@ using Umbraco.Web.Editors;
using Umbraco.Web.Features;
using Umbraco.Web.Models.ContentEditing;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Tests.Web.Controllers
{
@@ -85,7 +86,8 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance<IProfilingLogger>(),
Factory.GetInstance<IRuntimeState>(),
helper,
Factory.GetInstance<UmbracoMapper>());
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>());
return usersController;
}
@@ -35,6 +35,7 @@ using Umbraco.Web.Features;
using Umbraco.Web.Models.ContentEditing;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Umbraco.Core.Mapping;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Tests.Web.Controllers
{
@@ -90,7 +91,8 @@ namespace Umbraco.Tests.Web.Controllers
helper,
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>());
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>());
return usersController;
}
@@ -157,7 +159,8 @@ namespace Umbraco.Tests.Web.Controllers
helper,
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>());
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>());
return usersController;
}
@@ -195,7 +198,8 @@ namespace Umbraco.Tests.Web.Controllers
helper,
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>());
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>());
return usersController;
}
@@ -268,7 +272,8 @@ namespace Umbraco.Tests.Web.Controllers
helper,
Factory.GetInstance<IMediaFileSystem>(),
ShortStringHelper,
Factory.GetInstance<UmbracoMapper>());
Factory.GetInstance<UmbracoMapper>(),
Factory.GetInstance<IUmbracoSettingsSection>());
return usersController;
}
@@ -24,7 +24,7 @@
<title>Umbraco</title>
@Html.RenderCssHere(
new BasicPath("Umbraco", Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath)))
new BasicPath("Umbraco", Current.IOHelper.ResolveUrl(Model.GlobalSettings.UmbracoPath)))
@*Because we're lazy loading angular js, the embedded cloak style will not be loaded initially, but we need it*@
<style>
@@ -48,7 +48,7 @@
redirectUrl = Url.Action("AuthorizeUpgrade", "BackOffice")
});
}
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion)
@Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection)
<script type="text/javascript">
document.angularReady = function (app) {
@@ -110,7 +110,7 @@
on-login="hideLoginScreen()">
</umb-login>
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Current.Configs.Global(), Model.UmbracoVersion)
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Current.Configs.Global(), Model.UmbracoVersion, Current.Configs.Settings())
<script>
@@ -28,6 +28,7 @@ using Umbraco.Web.Composing;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Umbraco.Core.Mapping;
using Umbraco.Web.Models.Identity;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -43,11 +44,13 @@ namespace Umbraco.Web.Editors
private BackOfficeUserManager<BackOfficeIdentityUser> _userManager;
private BackOfficeSignInManager _signInManager;
private readonly IUserPasswordConfiguration _passwordConfiguration;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public AuthenticationController(IUserPasswordConfiguration passwordConfiguration, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, UmbracoMapper umbracoMapper)
public AuthenticationController(IUserPasswordConfiguration passwordConfiguration, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, UmbracoMapper umbracoMapper, IUmbracoSettingsSection umbracoSettingsSection)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, umbracoMapper)
{
_passwordConfiguration = passwordConfiguration ?? throw new ArgumentNullException(nameof(passwordConfiguration));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
protected BackOfficeUserManager<BackOfficeIdentityUser> UserManager => _userManager
@@ -291,7 +294,7 @@ namespace Umbraco.Web.Editors
{
// If this feature is switched off in configuration the UI will be amended to not make the request to reset password available.
// So this is just a server-side secondary check.
if (Current.Configs.Settings().Security.AllowPasswordReset == false)
if (_umbracoSettingsSection.Security.AllowPasswordReset == false)
{
throw new HttpResponseException(HttpStatusCode.BadRequest);
}
@@ -27,6 +27,8 @@ using Umbraco.Web.Models.Identity;
using Umbraco.Web.Security;
using Constants = Umbraco.Core.Constants;
using JArray = Newtonsoft.Json.Linq.JArray;
using Umbraco.Core.Configuration.Grid;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -44,14 +46,18 @@ namespace Umbraco.Web.Editors
private BackOfficeUserManager<BackOfficeIdentityUser> _userManager;
private BackOfficeSignInManager _signInManager;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IGridConfig _gridConfig;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public BackOfficeController(IManifestParser manifestParser, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IUmbracoVersion umbracoVersion)
public BackOfficeController(IManifestParser manifestParser, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IUmbracoVersion umbracoVersion, IGridConfig gridConfig, IUmbracoSettingsSection umbracoSettingsSection)
: base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger, umbracoHelper)
{
_manifestParser = manifestParser;
_features = features;
_runtimeState = runtimeState;
_umbracoVersion = umbracoVersion;
_gridConfig = gridConfig ?? throw new ArgumentNullException(nameof(gridConfig));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
protected BackOfficeSignInManager SignInManager => _signInManager ?? (_signInManager = OwinContext.GetBackOfficeSignInManager());
@@ -67,8 +73,8 @@ namespace Umbraco.Web.Editors
public async Task<ActionResult> Default()
{
return await RenderDefaultOrProcessExternalLoginAsync(
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion)));
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection)));
}
[HttpGet]
@@ -151,7 +157,7 @@ namespace Umbraco.Web.Editors
{
return await RenderDefaultOrProcessExternalLoginAsync(
//The default view to render when there is no external login info or errors
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection)),
//The ActionResult to perform if external login is successful
() => Redirect("/"));
}
@@ -206,7 +212,7 @@ namespace Umbraco.Web.Editors
var initCss = new CssInitialization(_manifestParser);
var files = initJs.OptimizeBackOfficeScriptFiles(HttpContext, JsInitialization.GetDefaultInitialization());
var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco");
var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco", GlobalSettings);
result += initCss.GetStylesheetInitialization(HttpContext);
return JavaScript(result);
@@ -245,8 +251,7 @@ namespace Umbraco.Web.Editors
[HttpGet]
public JsonNetResult GetGridConfig()
{
var gridConfig = Current.Configs.Grids();
return new JsonNetResult { Data = gridConfig.EditorsConfig.Editors, Formatting = Formatting.None };
return new JsonNetResult { Data = _gridConfig.EditorsConfig.Editors, Formatting = Formatting.None };
}
@@ -259,7 +264,7 @@ namespace Umbraco.Web.Editors
[MinifyJavaScriptResult(Order = 1)]
public JavaScriptResult ServerVariables()
{
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion);
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection);
//cache the result if debugging is disabled
var result = HttpContext.IsDebuggingEnabled
+4 -1
View File
@@ -1,4 +1,5 @@
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Web.Features;
namespace Umbraco.Web.Editors
@@ -6,15 +7,17 @@ namespace Umbraco.Web.Editors
public class BackOfficeModel
{
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion)
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection)
{
Features = features;
GlobalSettings = globalSettings;
UmbracoVersion = umbracoVersion;
UmbracoSettingsSection = umbracoSettingsSection;
}
public UmbracoFeatures Features { get; }
public IGlobalSettings GlobalSettings { get; }
public IUmbracoVersion UmbracoVersion { get; }
public IUmbracoSettingsSection UmbracoSettingsSection { get; }
}
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Models;
using Umbraco.Web.Features;
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Editors
private readonly UmbracoFeatures _features;
public IEnumerable<ILanguage> Languages { get; }
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages) : base(features, globalSettings, umbracoVersion)
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection) : base(features, globalSettings, umbracoVersion, umbracoSettingsSection)
{
_features = features;
Languages = languages;
@@ -21,6 +21,7 @@ using Umbraco.Web.Profiling;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.Trees;
using Constants = Umbraco.Core.Constants;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -36,8 +37,9 @@ namespace Umbraco.Web.Editors
private readonly HttpContextBase _httpContext;
private readonly IOwinContext _owinContext;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
internal BackOfficeServerVariables(UrlHelper urlHelper, IRuntimeState runtimeState, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion)
internal BackOfficeServerVariables(UrlHelper urlHelper, IRuntimeState runtimeState, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection)
{
_urlHelper = urlHelper;
_runtimeState = runtimeState;
@@ -46,6 +48,7 @@ namespace Umbraco.Web.Editors
_httpContext = _urlHelper.RequestContext.HttpContext;
_owinContext = _httpContext.GetOwinContext();
_umbracoVersion = umbracoVersion;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -101,7 +104,7 @@ namespace Umbraco.Web.Editors
/// <returns></returns>
internal Dictionary<string, object> GetServerVariables()
{
var globalSettings = Current.Configs.Global();
var globalSettings = _globalSettings;
var defaultVals = new Dictionary<string, object>
{
{
@@ -324,25 +327,25 @@ namespace Umbraco.Web.Editors
{"appPluginsPath", Current.IOHelper.ResolveUrl(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
{
"imageFileTypes",
string.Join(",", Current.Configs.Settings().Content.ImageFileTypes)
string.Join(",", _umbracoSettingsSection.Content.ImageFileTypes)
},
{
"disallowedUploadFiles",
string.Join(",", Current.Configs.Settings().Content.DisallowedUploadFiles)
string.Join(",", _umbracoSettingsSection.Content.DisallowedUploadFiles)
},
{
"allowedUploadFiles",
string.Join(",", Current.Configs.Settings().Content.AllowedUploadFiles)
string.Join(",", _umbracoSettingsSection.Content.AllowedUploadFiles)
},
{
"maxFileSize",
GetMaxRequestLength()
},
{"keepUserLoggedIn", Current.Configs.Settings().Security.KeepUserLoggedIn},
{"usernameIsEmail", Current.Configs.Settings().Security.UsernameIsEmail},
{"keepUserLoggedIn", _umbracoSettingsSection.Security.KeepUserLoggedIn},
{"usernameIsEmail", _umbracoSettingsSection.Security.UsernameIsEmail},
{"cssPath", Current.IOHelper.ResolveUrl(globalSettings.UmbracoCssPath).TrimEnd('/')},
{"allowPasswordReset", Current.Configs.Settings().Security.AllowPasswordReset},
{"loginBackgroundImage", Current.Configs.Settings().Content.LoginBackgroundImage},
{"allowPasswordReset", _umbracoSettingsSection.Security.AllowPasswordReset},
{"loginBackgroundImage", _umbracoSettingsSection.Content.LoginBackgroundImage},
{"showUserInvite", EmailSender.CanSendRequiredEmail(globalSettings)},
{"canSendRequiredEmail", EmailSender.CanSendRequiredEmail(globalSettings)},
}
@@ -130,11 +130,11 @@ namespace Umbraco.Web.Editors
Services.FileService.CreatePartialViewMacroFolder(virtualPath);
break;
case Core.Constants.Trees.Scripts:
virtualPath = NormalizeVirtualPath(name, Current.Configs.Global().UmbracoScriptsPath);
virtualPath = NormalizeVirtualPath(name, GlobalSettings.UmbracoScriptsPath);
Services.FileService.CreateScriptFolder(virtualPath);
break;
case Core.Constants.Trees.Stylesheets:
virtualPath = NormalizeVirtualPath(name, Current.Configs.Global().UmbracoCssPath);
virtualPath = NormalizeVirtualPath(name, GlobalSettings.UmbracoCssPath);
Services.FileService.CreateStyleSheetFolder(virtualPath);
break;
@@ -274,11 +274,11 @@ namespace Umbraco.Web.Editors
break;
case Core.Constants.Trees.Scripts:
codeFileDisplay = Mapper.Map<Script, CodeFileDisplay>(new Script(string.Empty));
codeFileDisplay.VirtualPath = Current.Configs.Global().UmbracoScriptsPath;
codeFileDisplay.VirtualPath = GlobalSettings.UmbracoScriptsPath;
break;
case Core.Constants.Trees.Stylesheets:
codeFileDisplay = Mapper.Map<Stylesheet, CodeFileDisplay>(new Stylesheet(string.Empty));
codeFileDisplay.VirtualPath = Current.Configs.Global().UmbracoCssPath;
codeFileDisplay.VirtualPath = GlobalSettings.UmbracoCssPath;
break;
default:
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Unsupported editortype"));
@@ -341,7 +341,7 @@ namespace Umbraco.Web.Editors
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Partial View Macro or folder found with the specified path");
case Core.Constants.Trees.Scripts:
if (IsDirectory(virtualPath, Current.Configs.Global().UmbracoScriptsPath))
if (IsDirectory(virtualPath, GlobalSettings.UmbracoScriptsPath))
{
Services.FileService.DeleteScriptFolder(virtualPath);
return Request.CreateResponse(HttpStatusCode.OK);
@@ -354,7 +354,7 @@ namespace Umbraco.Web.Editors
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Script or folder found with the specified path");
case Core.Constants.Trees.Stylesheets:
if (IsDirectory(virtualPath, Current.Configs.Global().UmbracoCssPath))
if (IsDirectory(virtualPath, GlobalSettings.UmbracoCssPath))
{
Services.FileService.DeleteStyleSheetFolder(virtualPath);
return Request.CreateResponse(HttpStatusCode.OK);
@@ -21,6 +21,7 @@ using Umbraco.Core.Strings;
using Umbraco.Web.Security;
using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Mapping;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -31,6 +32,7 @@ namespace Umbraco.Web.Editors
public class CurrentUserController : UmbracoAuthorizedJsonController
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public CurrentUserController(
IGlobalSettings globalSettings,
@@ -43,10 +45,12 @@ namespace Umbraco.Web.Editors
UmbracoHelper umbracoHelper,
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper)
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper, umbracoMapper)
{
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -180,7 +184,7 @@ namespace Umbraco.Web.Editors
public async Task<HttpResponseMessage> PostSetAvatar()
{
//borrow the logic from the user controller
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, Security.GetUserId().ResultOr(0));
return await UsersController.PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _umbracoSettingsSection, Security.GetUserId().ResultOr(0));
}
/// <summary>
@@ -23,6 +23,7 @@ using Umbraco.Core.Persistence;
using Constants = Umbraco.Core.Constants;
using Umbraco.Core.Mapping;
using System.Web.Http.Controllers;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -41,11 +42,13 @@ namespace Umbraco.Web.Editors
public class DataTypeController : BackOfficeNotificationsController
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public DataTypeController(PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IShortStringHelper shortStringHelper, UmbracoMapper umbracoMapper)
public DataTypeController(PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IShortStringHelper shortStringHelper, UmbracoMapper umbracoMapper, IUmbracoSettingsSection umbracoSettingsSection)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper, umbracoMapper)
{
_propertyEditors = propertyEditors;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -452,7 +455,7 @@ namespace Umbraco.Web.Editors
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
{
var datatypes = new List<DataTypeBasic>();
var showDeprecatedPropertyEditors = Current.Configs.Settings().Content.ShowDeprecatedPropertyEditors;
var showDeprecatedPropertyEditors = _umbracoSettingsSection.Content.ShowDeprecatedPropertyEditors;
var propertyEditors = Current.PropertyEditors
.Where(x=>x.IsDeprecated == false || showDeprecatedPropertyEditors);
+7 -3
View File
@@ -61,6 +61,8 @@ namespace Umbraco.Web.Editors
[MediaControllerControllerConfiguration]
public class MediaController : ContentControllerBase
{
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public MediaController(
ICultureDictionary cultureDictionary,
PropertyEditorCollection propertyEditors,
@@ -74,11 +76,13 @@ namespace Umbraco.Web.Editors
UmbracoHelper umbracoHelper,
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper)
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection)
: base(cultureDictionary, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper, umbracoMapper)
{
_propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors));
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -726,13 +730,13 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(ShortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (Current.Configs.Settings().Content.IsFileAllowedForUpload(ext))
if (_umbracoSettingsSection.Content.IsFileAllowedForUpload(ext))
{
var mediaType = Constants.Conventions.MediaTypes.File;
if (result.FormData["contentTypeAlias"] == Constants.Conventions.MediaTypes.AutoSelect)
{
if (Current.Configs.Settings().Content.ImageFileTypes.Contains(ext))
if (_umbracoSettingsSection.Content.ImageFileTypes.Contains(ext))
{
mediaType = Constants.Conventions.MediaTypes.Image;
}
+7 -3
View File
@@ -5,6 +5,7 @@ using System.Web.Mvc;
using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
using Umbraco.Web.Features;
@@ -25,6 +26,7 @@ namespace Umbraco.Web.Editors
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly ILocalizationService _localizationService;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public PreviewController(
UmbracoFeatures features,
@@ -32,7 +34,8 @@ namespace Umbraco.Web.Editors
IPublishedSnapshotService publishedSnapshotService,
IUmbracoContextAccessor umbracoContextAccessor,
ILocalizationService localizationService,
IUmbracoVersion umbracoVersion)
IUmbracoVersion umbracoVersion,
IUmbracoSettingsSection umbracoSettingsSection)
{
_features = features;
_globalSettings = globalSettings;
@@ -40,6 +43,7 @@ namespace Umbraco.Web.Editors
_umbracoContextAccessor = umbracoContextAccessor;
_localizationService = localizationService;
_umbracoVersion = umbracoVersion;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
[UmbracoAuthorize(redirectToUmbracoLogin: true)]
@@ -48,7 +52,7 @@ namespace Umbraco.Web.Editors
{
var availableLanguages = _localizationService.GetAllLanguages();
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages);
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection);
if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false)
{
@@ -71,7 +75,7 @@ namespace Umbraco.Web.Editors
public JavaScriptResult Application()
{
var files = JsInitialization.OptimizeScriptFiles(HttpContext, JsInitialization.GetPreviewInitialization());
var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco.preview");
var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco.preview", _globalSettings);
return JavaScript(result);
}
@@ -11,6 +11,7 @@ using Umbraco.Web.WebApi;
using File = System.IO.File;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -18,10 +19,12 @@ namespace Umbraco.Web.Editors
public class RedirectUrlManagementController : UmbracoAuthorizedApiController
{
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public RedirectUrlManagementController(ILogger logger)
public RedirectUrlManagementController(ILogger logger, IUmbracoSettingsSection umbracoSettingsSection)
{
_logger = logger;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -31,7 +34,7 @@ namespace Umbraco.Web.Editors
[HttpGet]
public IHttpActionResult GetEnableState()
{
var enabled = Current.Configs.Settings().WebRouting.DisableRedirectUrlTracking == false;
var enabled = _umbracoSettingsSection.WebRouting.DisableRedirectUrlTracking == false;
var userIsAdmin = UmbracoContext.Security.CurrentUser.IsAdmin();
return Ok(new { enabled, userIsAdmin });
}
+4 -2
View File
@@ -28,12 +28,14 @@ namespace Umbraco.Web.Editors
private readonly IMediaService _mediaService;
private readonly IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;
private readonly IShortStringHelper _shortStringHelper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public TinyMceController(IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IShortStringHelper shortStringHelper)
public TinyMceController(IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection)
{
_mediaService = mediaService;
_contentTypeBaseServiceProvider = contentTypeBaseServiceProvider;
_shortStringHelper = shortStringHelper;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
[HttpPost]
@@ -78,7 +80,7 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (Current.Configs.Settings().Content.IsFileAllowedForUpload(ext) == false || Current.Configs.Settings().Content.ImageFileTypes.Contains(ext) == false)
if (_umbracoSettingsSection.Content.IsFileAllowedForUpload(ext) == false || _umbracoSettingsSection.Content.ImageFileTypes.Contains(ext) == false)
{
// Throw some error - to say can't upload this IMG type
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "This is not an image filetype extension that is approved");
+5 -2
View File
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Umbraco.Core;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Web.Composing;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
@@ -15,17 +16,19 @@ namespace Umbraco.Web.Editors
public class TourController : UmbracoAuthorizedJsonController
{
private readonly TourFilterCollection _filters;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public TourController(TourFilterCollection filters)
public TourController(TourFilterCollection filters, IUmbracoSettingsSection umbracoSettingsSection)
{
_filters = filters;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
public IEnumerable<BackOfficeTourFile> GetTours()
{
var result = new List<BackOfficeTourFile>();
if (Current.Configs.Settings().BackOffice.Tours.EnableTours == false)
if (_umbracoSettingsSection.BackOffice.Tours.EnableTours == false)
return result;
var user = Composing.Current.UmbracoContext.Security.CurrentUser;
+13 -9
View File
@@ -35,6 +35,7 @@ using Constants = Umbraco.Core.Constants;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Task = System.Threading.Tasks.Task;
using Umbraco.Core.Mapping;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Editors
{
@@ -45,6 +46,7 @@ namespace Umbraco.Web.Editors
public class UsersController : UmbracoAuthorizedJsonController
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public UsersController(
IGlobalSettings globalSettings,
@@ -57,10 +59,12 @@ namespace Umbraco.Web.Editors
UmbracoHelper umbracoHelper,
IMediaFileSystem mediaFileSystem,
IShortStringHelper shortStringHelper,
UmbracoMapper umbracoMapper)
UmbracoMapper umbracoMapper,
IUmbracoSettingsSection umbracoSettingsSection)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper, umbracoMapper)
{
_mediaFileSystem = mediaFileSystem;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <summary>
@@ -81,10 +85,10 @@ namespace Umbraco.Web.Editors
[AdminUsersAuthorize]
public async Task<HttpResponseMessage> PostSetAvatar(int id)
{
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, id);
return await PostSetAvatarInternal(Request, Services.UserService, AppCaches.RuntimeCache, _mediaFileSystem, ShortStringHelper, _umbracoSettingsSection, id);
}
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, IShortStringHelper shortStringHelper, int id)
internal static async Task<HttpResponseMessage> PostSetAvatarInternal(HttpRequestMessage request, IUserService userService, IAppCache cache, IMediaFileSystem mediaFileSystem, IShortStringHelper shortStringHelper, IUmbracoSettingsSection umbracoSettingsSection, int id)
{
if (request.Content.IsMimeMultipartContent() == false)
{
@@ -119,7 +123,7 @@ namespace Umbraco.Web.Editors
var safeFileName = fileName.ToSafeFileName(shortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
if (Current.Configs.Settings().Content.DisallowedUploadFiles.Contains(ext) == false)
if (umbracoSettingsSection.Content.DisallowedUploadFiles.Contains(ext) == false)
{
//generate a path of known data, we don't want this path to be guessable
user.Avatar = "UserAvatars/" + (user.Id + safeFileName).GenerateHash<SHA1>() + "." + ext;
@@ -218,7 +222,7 @@ namespace Umbraco.Web.Editors
// so to do that here, we'll need to check if this current user is an admin and if not we should exclude all user who are
// also admins
var hideDisabledUsers = Current.Configs.Settings().Security.HideDisabledUsersInBackoffice;
var hideDisabledUsers = _umbracoSettingsSection.Security.HideDisabledUsersInBackoffice;
var excludeUserGroups = new string[0];
var isAdmin = Security.CurrentUser.IsAdmin();
if (isAdmin == false)
@@ -276,7 +280,7 @@ namespace Umbraco.Web.Editors
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
}
if (Current.Configs.Settings().Security.UsernameIsEmail)
if (_umbracoSettingsSection.Security.UsernameIsEmail)
{
//ensure they are the same if we're using it
userSave.Username = userSave.Email;
@@ -368,7 +372,7 @@ namespace Umbraco.Web.Editors
}
IUser user;
if (Current.Configs.Settings().Security.UsernameIsEmail)
if (_umbracoSettingsSection.Security.UsernameIsEmail)
{
//ensure it's the same
userSave.Username = userSave.Email;
@@ -442,7 +446,7 @@ namespace Umbraco.Web.Editors
if (user != null && (extraCheck == null || extraCheck(user)))
{
ModelState.AddModelError(
Current.Configs.Settings().Security.UsernameIsEmail ? "Email" : "Username",
_umbracoSettingsSection.Security.UsernameIsEmail ? "Email" : "Username",
"A user with the username already exists");
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
}
@@ -562,7 +566,7 @@ namespace Umbraco.Web.Editors
// if the found user has their email for username, we want to keep this synced when changing the email.
// we have already cross-checked above that the email isn't colliding with anything, so we can safely assign it here.
if (Current.Configs.Settings().Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
if (_umbracoSettingsSection.Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
{
userSave.Username = userSave.Email;
}
@@ -5,6 +5,7 @@ using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Services;
using Umbraco.Web.Install;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.HealthCheck.Checks.Permissions
{
@@ -28,10 +29,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
public class FolderAndFilePermissionsCheck : HealthCheck
{
private readonly ILocalizedTextService _textService;
private readonly IGlobalSettings _globalSettings;
public FolderAndFilePermissionsCheck(ILocalizedTextService textService)
public FolderAndFilePermissionsCheck(ILocalizedTextService textService, IGlobalSettings globalSettings)
{
_textService = textService;
_globalSettings = globalSettings;
}
/// <summary>
@@ -65,10 +68,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
{ Constants.SystemDirectories.Preview, PermissionCheckRequirement.Required },
{ Constants.SystemDirectories.AppPlugins, PermissionCheckRequirement.Required },
{ Constants.SystemDirectories.Config, PermissionCheckRequirement.Optional },
{ Current.Configs.Global().UmbracoCssPath, PermissionCheckRequirement.Optional },
{ Current.Configs.Global().UmbracoMediaPath, PermissionCheckRequirement.Optional },
{ Current.Configs.Global().UmbracoScriptsPath, PermissionCheckRequirement.Optional },
{ Current.Configs.Global().UmbracoPath, PermissionCheckRequirement.Optional },
{ _globalSettings.UmbracoCssPath, PermissionCheckRequirement.Optional },
{ _globalSettings.UmbracoMediaPath, PermissionCheckRequirement.Optional },
{ _globalSettings.UmbracoScriptsPath, PermissionCheckRequirement.Optional },
{ _globalSettings.UmbracoPath, PermissionCheckRequirement.Optional },
{ Constants.SystemDirectories.MvcViews, PermissionCheckRequirement.Optional }
};
@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Web.Editors;
using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Configuration.HealthChecks;
namespace Umbraco.Web.HealthCheck
{
@@ -20,12 +20,12 @@ namespace Umbraco.Web.HealthCheck
private readonly IList<Guid> _disabledCheckIds;
private readonly ILogger _logger;
public HealthCheckController(HealthCheckCollection checks, ILogger logger)
public HealthCheckController(HealthCheckCollection checks, ILogger logger, IHealthChecks healthChecks)
{
_checks = checks ?? throw new ArgumentNullException(nameof(checks));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
var healthCheckConfig = Current.Configs.HealthChecks();
var healthCheckConfig = healthChecks ?? throw new ArgumentNullException(nameof(healthChecks));
_disabledCheckIds = healthCheckConfig.DisabledChecks
.Select(x => x.Id)
.ToList();
@@ -8,6 +8,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
@@ -18,8 +19,9 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private readonly IRuntimeState _runtimeState;
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks): base(healthChecks)
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IUmbracoSettingsSection umbracoSettingsSection) : base(healthChecks)
{
var recipientEmail = Settings["recipientEmail"]?.Value;
if (string.IsNullOrWhiteSpace(recipientEmail))
@@ -34,6 +36,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
_runtimeState = runtimeState;
_logger = logger;
_globalSettings = globalSettings;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
public string RecipientEmail { get; }
@@ -72,7 +75,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private MailMessage CreateMailMessage(string subject, string message)
{
var to = Current.Configs.Settings().Content.NotificationEmailAddress;
var to = _umbracoSettingsSection.Content.NotificationEmailAddress;
if (string.IsNullOrWhiteSpace(subject))
subject = "Umbraco Health Check Status";
@@ -13,6 +13,7 @@ using Umbraco.Web.Models;
namespace Umbraco.Web
{
using Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Web.JavaScript;
/// <summary>
@@ -36,9 +37,9 @@ namespace Umbraco.Web
/// These are the bare minimal server variables that are required for the application to start without being authenticated,
/// we will load the rest of the server vars after the user is authenticated.
/// </remarks>
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion)
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection)
{
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion);
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection);
var minVars = serverVars.BareMinimumServerVariables();
var str = @"<script type=""text/javascript"">
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Install.Controllers
public ActionResult Index()
{
if (_runtime.Level == RuntimeLevel.Run)
return Redirect(Current.Configs.Global().UmbracoPath.EnsureEndsWith('/'));
return Redirect(_globalSettings.UmbracoPath.EnsureEndsWith('/'));
if (_runtime.Level == RuntimeLevel.Upgrade)
{
@@ -58,7 +58,7 @@ namespace Umbraco.Web.Install.Controllers
{
case ValidateRequestAttempt.FailedNoPrivileges:
case ValidateRequestAttempt.FailedNoContextId:
return Redirect(Current.Configs.Global().UmbracoPath + "/AuthorizeUpgrade?redir=" + Server.UrlEncode(Request.RawUrl));
return Redirect(_globalSettings.UmbracoPath + "/AuthorizeUpgrade?redir=" + Server.UrlEncode(Request.RawUrl));
}
}
@@ -66,7 +66,7 @@ namespace Umbraco.Web.Install.Controllers
ViewData.SetInstallApiBaseUrl(Url.GetUmbracoApiService("GetSetup", "InstallApi", "UmbracoInstall").TrimEnd("GetSetup"));
// get the base umbraco folder
ViewData.SetUmbracoBaseFolder(Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath));
ViewData.SetUmbracoBaseFolder(Current.IOHelper.ResolveUrl(_globalSettings.UmbracoPath));
_installHelper.InstallStatus(false, "");
+4 -2
View File
@@ -22,17 +22,19 @@ namespace Umbraco.Web.Install
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IConnectionStrings _connectionStrings;
private InstallationType? _installationType;
public InstallHelper(IUmbracoContextAccessor umbracoContextAccessor,
DatabaseBuilder databaseBuilder,
ILogger logger, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion)
ILogger logger, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IConnectionStrings connectionStrings)
{
_httpContext = umbracoContextAccessor.UmbracoContext.HttpContext;
_logger = logger;
_globalSettings = globalSettings;
_umbracoVersion = umbracoVersion;
_databaseBuilder = databaseBuilder;
_connectionStrings = connectionStrings ?? throw new ArgumentNullException(nameof(connectionStrings));
}
public InstallationType GetInstallationType()
@@ -112,7 +114,7 @@ namespace Umbraco.Web.Install
{
get
{
var databaseSettings = Current.Configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName];
if (_globalSettings.ConfigurationStatus.IsNullOrWhiteSpace()
&& databaseSettings.IsConnectionStringConfigured() == false)
{
@@ -1,10 +1,10 @@
using System;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Migrations.Install;
using Umbraco.Web.Install.Models;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.Install.InstallSteps
{
@@ -15,10 +15,12 @@ namespace Umbraco.Web.Install.InstallSteps
{
private readonly DatabaseBuilder _databaseBuilder;
private readonly ILogger _logger;
private readonly IConnectionStrings _connectionStrings;
public DatabaseConfigureStep(DatabaseBuilder databaseBuilder)
public DatabaseConfigureStep(DatabaseBuilder databaseBuilder, IConnectionStrings connectionStrings)
{
_databaseBuilder = databaseBuilder;
_connectionStrings = connectionStrings ?? throw new ArgumentNullException(nameof(connectionStrings));
}
public override Task<InstallSetupResult> ExecuteAsync(DatabaseModel database)
@@ -72,7 +74,7 @@ namespace Umbraco.Web.Install.InstallSteps
private bool ShouldDisplayView()
{
//If the connection string is already present in web.config we don't need to show the settings page and we jump to installing/upgrading.
var databaseSettings = Current.Configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName];
if (databaseSettings.IsConnectionStringConfigured())
{
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Core.Configuration;
@@ -20,14 +21,16 @@ namespace Umbraco.Web.Install.InstallSteps
private readonly ILogger _logger;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IGlobalSettings _globalSettings;
private readonly IConnectionStrings _connectionStrings;
public DatabaseUpgradeStep(DatabaseBuilder databaseBuilder, IRuntimeState runtime, ILogger logger, IUmbracoVersion umbracoVersion, IGlobalSettings globalSettings)
public DatabaseUpgradeStep(DatabaseBuilder databaseBuilder, IRuntimeState runtime, ILogger logger, IUmbracoVersion umbracoVersion, IGlobalSettings globalSettings, IConnectionStrings connectionStrings)
{
_databaseBuilder = databaseBuilder;
_runtime = runtime;
_logger = logger;
_umbracoVersion = umbracoVersion;
_globalSettings = globalSettings;
_connectionStrings = connectionStrings ?? throw new ArgumentNullException(nameof(connectionStrings));
}
public override Task<InstallSetupResult> ExecuteAsync(object model)
@@ -69,7 +72,7 @@ namespace Umbraco.Web.Install.InstallSteps
return false;
}
var databaseSettings = Current.Configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName];
if (databaseSettings.IsConnectionStringConfigured())
{
@@ -14,6 +14,7 @@ using Umbraco.Core.Services;
using Umbraco.Web.Install.Models;
using Umbraco.Web.Models.Identity;
using Umbraco.Web.Security;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Install.InstallSteps
{
@@ -35,14 +36,18 @@ namespace Umbraco.Web.Install.InstallSteps
private readonly IGlobalSettings _globalSettings;
private readonly IUserPasswordConfiguration _passwordConfiguration;
private readonly BackOfficeUserManager<BackOfficeIdentityUser> _userManager;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private readonly IConnectionStrings _connectionStrings;
public NewInstallStep(HttpContextBase http, IUserService userService, DatabaseBuilder databaseBuilder, IGlobalSettings globalSettings, IUserPasswordConfiguration passwordConfiguration)
public NewInstallStep(HttpContextBase http, IUserService userService, DatabaseBuilder databaseBuilder, IGlobalSettings globalSettings, IUserPasswordConfiguration passwordConfiguration, IUmbracoSettingsSection umbracoSettingsSection, IConnectionStrings connectionStrings)
{
_http = http;
_userService = userService;
_databaseBuilder = databaseBuilder;
_globalSettings = globalSettings;
_passwordConfiguration = passwordConfiguration ?? throw new ArgumentNullException(nameof(passwordConfiguration));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_connectionStrings = connectionStrings ?? throw new ArgumentNullException(nameof(connectionStrings));
_userManager = _http.GetOwinContext().GetBackOfficeUserManager();
}
@@ -122,7 +127,7 @@ namespace Umbraco.Web.Install.InstallSteps
public override bool RequiresExecution(UserModel model)
{
//now we have to check if this is really a new install, the db might be configured and might contain data
var databaseSettings = Current.Configs.ConnectionStrings()[Constants.System.UmbracoConnectionName];
var databaseSettings = _connectionStrings[Constants.System.UmbracoConnectionName];
//if there's already a version then there should def be a user but in some cases someone may have
// left a version number in there but cleared out their db conn string, in that case, it's really a new install.
@@ -133,7 +138,7 @@ namespace Umbraco.Web.Install.InstallSteps
// In this one case when it's a brand new install and nothing has been configured, make sure the
// back office cookie is cleared so there's no old cookies lying around causing problems
_http.ExpireCookie(Current.Configs.Settings().Security.AuthCookieName);
_http.ExpireCookie(_umbracoSettingsSection.Security.AuthCookieName);
return true;
}
@@ -9,6 +9,7 @@ using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Manifest;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.JavaScript
{
@@ -42,7 +43,7 @@ namespace Umbraco.Web.JavaScript
/// The angular module name to boot
/// </param>
/// <returns></returns>
public static string GetJavascriptInitialization(HttpContextBase httpContext, IEnumerable<string> scripts, string angularModule)
public static string GetJavascriptInitialization(HttpContextBase httpContext, IEnumerable<string> scripts, string angularModule, IGlobalSettings globalSettings)
{
var jarray = new StringBuilder();
jarray.AppendLine("[");
@@ -58,7 +59,7 @@ namespace Umbraco.Web.JavaScript
}
jarray.Append("]");
return WriteScript(jarray.ToString(), Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath), angularModule);
return WriteScript(jarray.ToString(), Current.IOHelper.ResolveUrl(globalSettings.UmbracoPath), angularModule);
}
/// <summary>
@@ -2,6 +2,7 @@
using ClientDependency.Core.Controls;
using ClientDependency.Core.FileRegistration.Providers;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Web.Composing;
namespace Umbraco.Web.JavaScript
@@ -15,10 +16,10 @@ namespace Umbraco.Web.JavaScript
/// <summary>
/// Set the defaults
/// </summary>
public UmbracoClientDependencyLoader()
public UmbracoClientDependencyLoader(IGlobalSettings globalSettings)
: base()
{
this.AddPath("UmbracoRoot", Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath));
this.AddPath("UmbracoRoot", Current.IOHelper.ResolveUrl(globalSettings.UmbracoPath));
this.ProviderName = LoaderControlProvider.DefaultName;
}
@@ -27,7 +28,7 @@ namespace Umbraco.Web.JavaScript
{
if (ClientDependencyLoader.Instance == null)
{
var loader = new UmbracoClientDependencyLoader();
var loader = new UmbracoClientDependencyLoader(Current.Factory.GetInstance<IGlobalSettings>());
parent.Controls.Add(loader);
isNew = true;
return loader;
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
@@ -15,11 +16,13 @@ namespace Umbraco.Web.Models.Mapping
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger)
public DataTypeMapDefinition(PropertyEditorCollection propertyEditors, ILogger logger, IUmbracoSettingsSection umbracoSettingsSection)
{
_propertyEditors = propertyEditors;
_logger = logger;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
private static readonly int[] SystemIds =
@@ -126,7 +129,7 @@ namespace Umbraco.Web.Models.Mapping
private IEnumerable<PropertyEditorBasic> MapAvailableEditors(IDataType source, MapperContext context)
{
var contentSection = Current.Configs.Settings().Content;
var contentSection = _umbracoSettingsSection.Content;
var properties = _propertyEditors
.Where(x => !x.IsDeprecated || contentSection.ShowDeprecatedPropertyEditors || source.EditorAlias == x.Alias)
.OrderBy(x => x.Name);
@@ -1,5 +1,4 @@
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
@@ -8,6 +7,8 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Trees;
using Umbraco.Core.Configuration.UmbracoSettings;
using System;
namespace Umbraco.Web.Models.Mapping
{
@@ -22,15 +23,17 @@ namespace Umbraco.Web.Models.Mapping
private readonly IMediaTypeService _mediaTypeService;
private readonly PropertyEditorCollection _propertyEditorCollection;
private readonly TabsAndPropertiesMapper<IMedia> _tabsAndPropertiesMapper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public MediaMapDefinition(ICultureDictionary cultureDictionary, ILogger logger, CommonMapper commonMapper, IMediaService mediaService, IMediaTypeService mediaTypeService,
ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditorCollection)
ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditorCollection, IUmbracoSettingsSection umbracoSettingsSection)
{
_logger = logger;
_commonMapper = commonMapper;
_mediaService = mediaService;
_mediaTypeService = mediaTypeService;
_propertyEditorCollection = propertyEditorCollection;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
_tabsAndPropertiesMapper = new TabsAndPropertiesMapper<IMedia>(cultureDictionary, localizedTextService);
}
@@ -61,7 +64,7 @@ namespace Umbraco.Web.Models.Mapping
target.Id = source.Id;
target.IsChildOfListView = DermineIsChildOfListView(source);
target.Key = source.Key;
target.MediaLink = string.Join(",", source.GetUrls(Current.Configs.Settings().Content, _logger, _propertyEditorCollection));
target.MediaLink = string.Join(",", source.GetUrls(_umbracoSettingsSection.Content, _logger, _propertyEditorCollection));
target.Name = source.Name;
target.Owner = _commonMapper.GetOwner(source, context);
target.ParentId = source.ParentId;
+13 -4
View File
@@ -5,6 +5,8 @@ using System.Web.Mvc;
using System.Web.WebPages;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -20,6 +22,9 @@ namespace Umbraco.Web.Mvc
/// </summary>
public abstract class UmbracoViewPage<TModel> : WebViewPage<TModel>
{
private readonly IGlobalSettings _globalSettings;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private UmbracoContext _umbracoContext;
private UmbracoHelper _helper;
@@ -104,15 +109,19 @@ namespace Umbraco.Web.Mvc
protected UmbracoViewPage()
: this(
Current.Factory.GetInstance<ServiceContext>(),
Current.Factory.GetInstance<AppCaches>()
Current.Factory.GetInstance<AppCaches>(),
Current.Factory.GetInstance<IGlobalSettings>(),
Current.Factory.GetInstance<IUmbracoSettingsSection>()
)
{
}
protected UmbracoViewPage(ServiceContext services, AppCaches appCaches)
protected UmbracoViewPage(ServiceContext services, AppCaches appCaches, IGlobalSettings globalSettings, IUmbracoSettingsSection umbracoSettingsSection)
{
Services = services;
AppCaches = appCaches;
_globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
// view logic below:
@@ -210,8 +219,8 @@ namespace Umbraco.Web.Mvc
{
// creating previewBadge markup
markupToInject =
string.Format(Current.Configs.Settings().Content.PreviewBadge,
Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath),
string.Format(_umbracoSettingsSection.Content.PreviewBadge,
Current.IOHelper.ResolveUrl(_globalSettings.UmbracoPath),
Server.UrlEncode(Current.UmbracoContext.HttpContext.Request.Url?.PathAndQuery),
Current.UmbracoContext.PublishedRequest.PublishedContent.Id);
}
+5 -2
View File
@@ -8,6 +8,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Macros;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Routing
{
@@ -18,6 +19,7 @@ namespace Umbraco.Web.Routing
public class PublishedRequest
{
private readonly IPublishedRouter _publishedRouter;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private bool _readonly; // after prepared
private bool _readonlyUri; // after preparing
@@ -35,10 +37,11 @@ namespace Umbraco.Web.Routing
/// <param name="publishedRouter">The published router.</param>
/// <param name="umbracoContext">The Umbraco context.</param>
/// <param name="uri">The request <c>Uri</c>.</param>
internal PublishedRequest(IPublishedRouter publishedRouter, UmbracoContext umbracoContext, Uri uri = null)
internal PublishedRequest(IPublishedRouter publishedRouter, UmbracoContext umbracoContext, IUmbracoSettingsSection umbracoSettingsSection, Uri uri = null)
{
UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext));
_publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
Uri = uri ?? umbracoContext.CleanedUmbracoUrl;
}
@@ -177,7 +180,7 @@ namespace Umbraco.Web.Routing
IsInternalRedirectPublishedContent = isInternalRedirect;
// must restore the template if it's an internal redirect & the config option is set
if (isInternalRedirect && Current.Configs.Settings().WebRouting.InternalRedirectPreservesTemplate)
if (isInternalRedirect && _umbracoSettingsSection.WebRouting.InternalRedirectPreservesTemplate)
{
// restore
TemplateModel = template;
+5 -2
View File
@@ -27,6 +27,7 @@ namespace Umbraco.Web.Routing
private readonly IProfilingLogger _profilingLogger;
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
/// <summary>
/// Initializes a new instance of the <see cref="PublishedRouter"/> class.
@@ -37,7 +38,8 @@ namespace Umbraco.Web.Routing
IContentLastChanceFinder contentLastChanceFinder,
IVariationContextAccessor variationContextAccessor,
ServiceContext services,
IProfilingLogger proflog)
IProfilingLogger proflog,
IUmbracoSettingsSection umbracoSettingsSection)
{
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
@@ -46,12 +48,13 @@ namespace Umbraco.Web.Routing
_profilingLogger = proflog ?? throw new ArgumentNullException(nameof(proflog));
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
_logger = proflog;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
/// <inheritdoc />
public PublishedRequest CreateRequest(UmbracoContext umbracoContext, Uri uri = null)
{
return new PublishedRequest(this, umbracoContext, uri ?? umbracoContext.CleanedUmbracoUrl);
return new PublishedRequest(this, umbracoContext, _umbracoSettingsSection, uri ?? umbracoContext.CleanedUmbracoUrl);
}
#region Request
@@ -228,7 +228,7 @@ namespace Umbraco.Web.Runtime
// register published router
composition.RegisterUnique<IPublishedRouter, PublishedRouter>();
composition.Register(_ => Current.Configs.Settings().WebRouting);
composition.Register(_ => composition.Configs.Settings().WebRouting);
// register preview SignalR hub
composition.RegisterUnique(_ => GlobalHost.ConnectionManager.GetHubContext<PreviewHub>());
@@ -2,10 +2,10 @@
using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Sync;
using Umbraco.Web.HealthCheck;
using Umbraco.Core.Configuration.HealthChecks;
namespace Umbraco.Web.Scheduling
{
@@ -15,17 +15,18 @@ namespace Umbraco.Web.Scheduling
private readonly HealthCheckCollection _healthChecks;
private readonly HealthCheckNotificationMethodCollection _notifications;
private readonly IProfilingLogger _logger;
private readonly IHealthChecks _healthChecksConfig;
public HealthCheckNotifier(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
IRuntimeState runtimeState,
IProfilingLogger logger)
IRuntimeState runtimeState, IProfilingLogger logger, IHealthChecks healthChecksConfig)
: base(runner, delayMilliseconds, periodMilliseconds)
{
_healthChecks = healthChecks;
_notifications = notifications;
_runtimeState = runtimeState;
_logger = logger;
_healthChecksConfig = healthChecksConfig;
}
public override async Task<bool> PerformRunAsync(CancellationToken token)
@@ -52,7 +53,7 @@ namespace Umbraco.Web.Scheduling
using (_logger.DebugDuration<HealthCheckNotifier>("Health checks executing", "Health checks complete"))
{
var healthCheckConfig = Current.Configs.HealthChecks();
var healthCheckConfig = _healthChecksConfig;
// Don't notify for any checks that are disabled, nor for any disabled
// just for notifications
@@ -32,6 +32,8 @@ namespace Umbraco.Web.Scheduling
private readonly HealthCheckCollection _healthChecks;
private readonly HealthCheckNotificationMethodCollection _notifications;
private readonly IUmbracoContextFactory _umbracoContextFactory;
private readonly IHealthChecks _healthChecksConfig;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
private BackgroundTaskRunner<IBackgroundTask> _keepAliveRunner;
private BackgroundTaskRunner<IBackgroundTask> _publishingRunner;
@@ -47,7 +49,9 @@ namespace Umbraco.Web.Scheduling
public SchedulerComponent(IRuntimeState runtime,
IContentService contentService, IAuditService auditService,
HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications,
IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger, IHostingEnvironment hostingEnvironment)
IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger,
IHostingEnvironment hostingEnvironment, IHealthChecks healthChecksConfig,
IUmbracoSettingsSection umbracoSettingsSection)
{
_runtime = runtime;
_contentService = contentService;
@@ -59,6 +63,8 @@ namespace Umbraco.Web.Scheduling
_healthChecks = healthChecks;
_notifications = notifications;
_healthChecksConfig = healthChecksConfig ?? throw new ArgumentNullException(nameof(healthChecksConfig));
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
}
public void Initialize()
@@ -97,7 +103,7 @@ namespace Umbraco.Web.Scheduling
LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () =>
{
_logger.Debug<SchedulerComponent>("Initializing the scheduler");
var settings = Current.Configs.Settings();
var settings = _umbracoSettingsSection;
var tasks = new List<IBackgroundTask>();
@@ -110,7 +116,7 @@ namespace Umbraco.Web.Scheduling
tasks.Add(RegisterLogScrubber(settings));
tasks.Add(RegisterTempFileCleanup());
var healthCheckConfig = Current.Configs.HealthChecks();
var healthCheckConfig = _healthChecksConfig;
if (healthCheckConfig.NotificationSettings.Enabled)
tasks.Add(RegisterHealthCheckNotifier(healthCheckConfig, _healthChecks, _notifications, _logger));
@@ -157,7 +163,7 @@ namespace Umbraco.Web.Scheduling
}
var periodInMilliseconds = healthCheckConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000;
var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger);
var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger, _healthChecksConfig);
_healthCheckRunner.TryAdd(task);
return task;
}
@@ -152,9 +152,10 @@ namespace Umbraco.Web.Security
IUserService userService,
IGlobalSettings globalSettings,
ISecuritySection securitySection,
IIOHelper ioHelper)
IIOHelper ioHelper,
IUmbracoSettingsSection umbracoSettingsSection)
{
return app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, userService, globalSettings, securitySection, ioHelper, PipelineStage.Authenticate);
return app.UseUmbracoBackOfficeCookieAuthentication(umbracoContextAccessor, runtimeState, userService, globalSettings, securitySection, ioHelper, PipelineStage.Authenticate, umbracoSettingsSection);
}
/// <summary>
@@ -178,12 +179,13 @@ namespace Umbraco.Web.Security
IGlobalSettings globalSettings,
ISecuritySection securitySection,
IIOHelper ioHelper,
PipelineStage stage)
PipelineStage stage,
IUmbracoSettingsSection umbracoSettingsSection)
{
//Create the default options and provider
var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySection, ioHelper);
authOptions.Provider = new BackOfficeCookieAuthenticationProvider(userService, runtimeState, globalSettings, ioHelper)
authOptions.Provider = new BackOfficeCookieAuthenticationProvider(userService, runtimeState, globalSettings, ioHelper, umbracoSettingsSection)
{
// Enables the application to validate the security stamp when the user
// logs in. This is a security feature which is used when you
@@ -10,6 +10,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Web.Security
{
@@ -19,13 +20,15 @@ namespace Umbraco.Web.Security
private readonly IRuntimeState _runtimeState;
private readonly IGlobalSettings _globalSettings;
private readonly IIOHelper _ioHelper;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
public BackOfficeCookieAuthenticationProvider(IUserService userService, IRuntimeState runtimeState, IGlobalSettings globalSettings, IIOHelper ioHelper)
public BackOfficeCookieAuthenticationProvider(IUserService userService, IRuntimeState runtimeState, IGlobalSettings globalSettings, IIOHelper ioHelper, IUmbracoSettingsSection umbracoSettingsSection)
{
_userService = userService;
_runtimeState = runtimeState;
_globalSettings = globalSettings;
_ioHelper = ioHelper;
_umbracoSettingsSection = umbracoSettingsSection;
}
public override void ResponseSignIn(CookieResponseSignInContext context)
@@ -69,7 +72,7 @@ namespace Umbraco.Web.Security
Expires = DateTime.Now.AddYears(-1),
Path = "/"
});
context.Response.Cookies.Append(Current.Configs.Settings().Security.AuthCookieName, "", new CookieOptions
context.Response.Cookies.Append(_umbracoSettingsSection.Security.AuthCookieName, "", new CookieOptions
{
Expires = DateTime.Now.AddYears(-1),
Path = "/"
+3 -3
View File
@@ -196,7 +196,7 @@ namespace Umbraco.Web.Security
var user = CurrentUser;
// Check for console access
if (user == null || (requiresApproval && user.IsApproved == false) || (user.IsLockedOut && RequestIsInUmbracoApplication(_httpContext)))
if (user == null || (requiresApproval && user.IsApproved == false) || (user.IsLockedOut && RequestIsInUmbracoApplication(_httpContext, _globalSettings)))
{
if (throwExceptions) throw new ArgumentException("You have no privileges to the umbraco console. Please contact your administrator");
return ValidateRequestAttempt.FailedNoPrivileges;
@@ -205,9 +205,9 @@ namespace Umbraco.Web.Security
}
private static bool RequestIsInUmbracoApplication(HttpContextBase context)
private static bool RequestIsInUmbracoApplication(HttpContextBase context, IGlobalSettings globalSettings)
{
return context.Request.Path.ToLower().IndexOf(Current.IOHelper.ResolveUrl(Current.Configs.Global().UmbracoPath).ToLower(), StringComparison.Ordinal) > -1;
return context.Request.Path.ToLower().IndexOf(Current.IOHelper.ResolveUrl(globalSettings.UmbracoPath).ToLower(), StringComparison.Ordinal) > -1;
}
/// <summary>
+1 -2
View File
@@ -6,7 +6,6 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Mapping;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Net;
using Umbraco.Web;
@@ -103,7 +102,7 @@ namespace Umbraco.Web
// Ensure owin is configured for Umbraco back office authentication.
// Front-end OWIN cookie configuration must be declared after this code.
app
.UseUmbracoBackOfficeCookieAuthentication(UmbracoContextAccessor, RuntimeState, Services.UserService, GlobalSettings, UmbracoSettings.Security, IOHelper, PipelineStage.Authenticate)
.UseUmbracoBackOfficeCookieAuthentication(UmbracoContextAccessor, RuntimeState, Services.UserService, GlobalSettings, UmbracoSettings.Security, IOHelper, PipelineStage.Authenticate, UmbracoSettings)
.UseUmbracoBackOfficeExternalCookieAuthentication(UmbracoContextAccessor, RuntimeState, GlobalSettings, IOHelper, PipelineStage.Authenticate)
.UseUmbracoPreviewAuthentication(UmbracoContextAccessor, RuntimeState, GlobalSettings, UmbracoSettings.Security, IOHelper, PipelineStage.Authorize);
}