public UmbracoRequestMiddleware( ILogger <UmbracoRequestMiddleware> logger, IUmbracoContextFactory umbracoContextFactory, IRequestCache requestCache, IEventAggregator eventAggregator, IProfiler profiler, IHostingEnvironment hostingEnvironment, UmbracoRequestPaths umbracoRequestPaths, BackOfficeWebAssets backOfficeWebAssets, IOptionsMonitor <SmidgeOptions> smidgeOptions, IRuntimeState runtimeState, IVariationContextAccessor variationContextAccessor, IDefaultCultureAccessor defaultCultureAccessor) : this( logger, umbracoContextFactory, requestCache, eventAggregator, profiler, hostingEnvironment, umbracoRequestPaths, backOfficeWebAssets, smidgeOptions, runtimeState, variationContextAccessor, defaultCultureAccessor, StaticServiceProvider.Instance.GetRequiredService <IOptions <UmbracoRequestOptions> >()) { }
/// <summary> /// Returns true if the request is for a client side extension /// </summary> public static bool IsClientSideRequest(this HttpRequest request) { PathString absPath = request.Path; UmbracoRequestPaths umbReqPaths = request.HttpContext.RequestServices.GetService <UmbracoRequestPaths>(); return(umbReqPaths.IsClientSideRequest(absPath)); }
/// <summary> /// Initializes a new instance of the <see cref="UmbracoRequestMiddleware"/> class. /// </summary> public UmbracoRequestMiddleware( ILogger <UmbracoRequestMiddleware> logger, IUmbracoContextFactory umbracoContextFactory, IRequestCache requestCache, IEventAggregator eventAggregator, IProfiler profiler, IHostingEnvironment hostingEnvironment, UmbracoRequestPaths umbracoRequestPaths, BackOfficeWebAssets backOfficeWebAssets, IOptionsMonitor <SmidgeOptions> smidgeOptions, IRuntimeState runtimeState, IVariationContextAccessor variationContextAccessor, IDefaultCultureAccessor defaultCultureAccessor, IOptions <UmbracoRequestOptions> umbracoRequestOptions) { _logger = logger; _umbracoContextFactory = umbracoContextFactory; _requestCache = requestCache; _eventAggregator = eventAggregator; _hostingEnvironment = hostingEnvironment; _umbracoRequestPaths = umbracoRequestPaths; _backOfficeWebAssets = backOfficeWebAssets; _runtimeState = runtimeState; _variationContextAccessor = variationContextAccessor; _defaultCultureAccessor = defaultCultureAccessor; _umbracoRequestOptions = umbracoRequestOptions; _smidgeOptions = smidgeOptions.CurrentValue; _profiler = profiler as WebProfiler; // Ignore if not a WebProfiler smidgeOptions.OnChange(x => _smidgeOptions = x); }
// initializes a new instance of the UmbracoContext class // internal for unit tests // otherwise it's used by EnsureContext above // warn: does *not* manage setting any IUmbracoContextAccessor internal UmbracoContext( IPublishedSnapshotService publishedSnapshotService, UmbracoRequestPaths umbracoRequestPaths, IHostingEnvironment hostingEnvironment, UriUtility uriUtility, ICookieManager cookieManager, IHttpContextAccessor httpContextAccessor) { if (publishedSnapshotService == null) { throw new ArgumentNullException(nameof(publishedSnapshotService)); } _uriUtility = uriUtility; _hostingEnvironment = hostingEnvironment; _cookieManager = cookieManager; _httpContextAccessor = httpContextAccessor; ObjectCreated = DateTime.Now; UmbracoRequestId = Guid.NewGuid(); _umbracoRequestPaths = umbracoRequestPaths; // beware - we cannot expect a current user here, so detecting preview mode must be a lazy thing _publishedSnapshot = new Lazy <IPublishedSnapshot>(() => publishedSnapshotService.CreatePublishedSnapshot(PreviewToken)); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigureBackOfficeCookieOptions" /> class. /// </summary> /// <param name="serviceProvider">The <see cref="IServiceProvider" /></param> /// <param name="umbracoContextAccessor">The <see cref="IUmbracoContextAccessor" /></param> /// <param name="securitySettings">The <see cref="SecuritySettings" /> options</param> /// <param name="globalSettings">The <see cref="GlobalSettings" /> options</param> /// <param name="hostingEnvironment">The <see cref="IHostingEnvironment" /></param> /// <param name="runtimeState">The <see cref="IRuntimeState" /></param> /// <param name="dataProtection">The <see cref="IDataProtectionProvider" /></param> /// <param name="userService">The <see cref="IUserService" /></param> /// <param name="ipResolver">The <see cref="IIpResolver" /></param> /// <param name="systemClock">The <see cref="ISystemClock" /></param> /// <param name="umbracoRequestPaths">The <see cref="UmbracoRequestPaths"/></param> /// <param name="basicAuthService">The <see cref="IBasicAuthService"/></param> public ConfigureBackOfficeCookieOptions( IServiceProvider serviceProvider, IUmbracoContextAccessor umbracoContextAccessor, IOptions <SecuritySettings> securitySettings, IOptions <GlobalSettings> globalSettings, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, IDataProtectionProvider dataProtection, IUserService userService, IIpResolver ipResolver, ISystemClock systemClock, UmbracoRequestPaths umbracoRequestPaths, IBasicAuthService basicAuthService) { _serviceProvider = serviceProvider; _umbracoContextAccessor = umbracoContextAccessor; _securitySettings = securitySettings.Value; _globalSettings = globalSettings.Value; _hostingEnvironment = hostingEnvironment; _runtimeState = runtimeState; _dataProtection = dataProtection; _userService = userService; _ipResolver = ipResolver; _systemClock = systemClock; _umbracoRequestPaths = umbracoRequestPaths; _basicAuthService = basicAuthService; }
public void Is_Back_Office_Request(string input, string virtualPath, bool expected) { var source = new Uri(input); var hostingEnvironment = CreateHostingEnvironment(virtualPath); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); Assert.AreEqual(expected, umbracoRequestPaths.IsBackOfficeRequest(source.AbsolutePath)); }
public void Is_Installer_Request(string input, bool expected) { var source = new Uri(input); var hostingEnvironment = CreateHostingEnvironment(); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); Assert.AreEqual(expected, umbracoRequestPaths.IsInstallerRequest(source.AbsolutePath)); }
/// <summary> /// Initializes a new instance of the <see cref="BackOfficeCookieManager" /> class. /// </summary> public BackOfficeCookieManager( IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtime, UmbracoRequestPaths umbracoRequestPaths, IBasicAuthService basicAuthService) : this(umbracoContextAccessor, runtime, null, umbracoRequestPaths, basicAuthService) { }
public void Is_Client_Side_Request(string url, bool assert) { IHostingEnvironment hostingEnvironment = CreateHostingEnvironment(); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); var uri = new Uri("http://test.com" + url); var result = umbracoRequestPaths.IsClientSideRequest(uri.AbsolutePath); Assert.AreEqual(assert, result); }
public void Is_Client_Side_Request_InvalidPath_ReturnFalse() { IHostingEnvironment hostingEnvironment = CreateHostingEnvironment(); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); // This URL is invalid. Default to false when the extension cannot be determined var uri = new Uri("http://test.com/installing-modules+foobar+\"yipee\""); var result = umbracoRequestPaths.IsClientSideRequest(uri.AbsolutePath); Assert.AreEqual(false, result); }
/// <summary> /// Initializes a new instance of the <see cref="BackOfficeCookieManager" /> class. /// </summary> public BackOfficeCookieManager( IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtime, IEnumerable <string>?explicitPaths, UmbracoRequestPaths umbracoRequestPaths, IBasicAuthService basicAuthService) { _umbracoContextAccessor = umbracoContextAccessor; _runtime = runtime; _explicitPaths = explicitPaths?.ToArray(); _umbracoRequestPaths = umbracoRequestPaths; _basicAuthService = basicAuthService; }
/// <summary> /// Initializes a new instance of the <see cref="UmbracoContextFactory"/> class. /// </summary> public UmbracoContextFactory( IUmbracoContextAccessor umbracoContextAccessor, IPublishedSnapshotService publishedSnapshotService, UmbracoRequestPaths umbracoRequestPaths, IHostingEnvironment hostingEnvironment, UriUtility uriUtility, ICookieManager cookieManager, IHttpContextAccessor httpContextAccessor) { _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); _umbracoRequestPaths = umbracoRequestPaths ?? throw new ArgumentNullException(nameof(umbracoRequestPaths)); _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); _uriUtility = uriUtility ?? throw new ArgumentNullException(nameof(uriUtility)); _cookieManager = cookieManager ?? throw new ArgumentNullException(nameof(cookieManager)); _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); }
public MemberCookieManager(IRuntimeState runtime, UmbracoRequestPaths umbracoRequestPaths) { _runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); _umbracoRequestPaths = umbracoRequestPaths ?? throw new ArgumentNullException(nameof(umbracoRequestPaths)); }
public ConfigureMemberCookieOptions(IRuntimeState runtimeState, UmbracoRequestPaths umbracoRequestPaths) { _runtimeState = runtimeState; _umbracoRequestPaths = umbracoRequestPaths; }