Ejemplo n.º 1
0
 public CoreRuntime(
     ILoggerFactory loggerFactory,
     IRuntimeState state,
     ComponentCollection components,
     IApplicationShutdownRegistry applicationShutdownRegistry,
     IProfilingLogger profilingLogger,
     IMainDom mainDom,
     IUmbracoDatabaseFactory databaseFactory,
     IEventAggregator eventAggregator,
     IHostingEnvironment hostingEnvironment,
     IUmbracoVersion umbracoVersion)
     : this(
         loggerFactory,
         state,
         components,
         applicationShutdownRegistry,
         profilingLogger,
         mainDom,
         databaseFactory,
         eventAggregator,
         hostingEnvironment,
         umbracoVersion,
         null)
 {
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HealthCheckNotifier"/> class.
        /// </summary>
        /// <param name="healthChecksSettings">The configuration for health check settings.</param>
        /// <param name="healthChecks">The collection of healthchecks.</param>
        /// <param name="notifications">The collection of healthcheck notification methods.</param>
        /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param>
        /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param>
        /// <param name="mainDom">Representation of the main application domain.</param>
        /// <param name="scopeProvider">Provides scopes for database operations.</param>
        /// <param name="logger">The typed logger.</param>
        /// <param name="profilingLogger">The profiling logger.</param>
        /// <param name="cronTabParser">Parser of crontab expressions.</param>
        public HealthCheckNotifier(
            IOptionsMonitor <HealthChecksSettings> healthChecksSettings,
            HealthCheckCollection healthChecks,
            HealthCheckNotificationMethodCollection notifications,
            IRuntimeState runtimeState,
            IServerRoleAccessor serverRegistrar,
            IMainDom mainDom,
            IScopeProvider scopeProvider,
            ILogger <HealthCheckNotifier> logger,
            IProfilingLogger profilingLogger,
            ICronTabParser cronTabParser)
            : base(
                logger,
                healthChecksSettings.CurrentValue.Notification.Period,
                healthChecksSettings.CurrentValue.GetNotificationDelay(cronTabParser, DateTime.Now, DefaultDelay))
        {
            _healthChecksSettings = healthChecksSettings.CurrentValue;
            _healthChecks         = healthChecks;
            _notifications        = notifications;
            _runtimeState         = runtimeState;
            _serverRegistrar      = serverRegistrar;
            _mainDom         = mainDom;
            _scopeProvider   = scopeProvider;
            _logger          = logger;
            _profilingLogger = profilingLogger;

            healthChecksSettings.OnChange(x =>
            {
                _healthChecksSettings = x;
                ChangePeriod(x.Notification.Period);
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseBuilder"/> class.
 /// </summary>
 public DatabaseBuilder(
     IScopeProvider scopeProvider,
     IUmbracoDatabaseFactory databaseFactory,
     IRuntimeState runtimeState,
     ILoggerFactory loggerFactory,
     IKeyValueService keyValueService,
     IDbProviderFactoryCreator dbProviderFactoryCreator,
     IConfigManipulator configManipulator,
     IOptionsMonitor <GlobalSettings> globalSettings,
     IOptionsMonitor <ConnectionStrings> connectionStrings,
     IMigrationPlanExecutor migrationPlanExecutor,
     DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory)
 {
     _scopeProvider                = scopeProvider;
     _databaseFactory              = databaseFactory;
     _runtimeState                 = runtimeState;
     _logger                       = loggerFactory.CreateLogger <DatabaseBuilder>();
     _keyValueService              = keyValueService;
     _dbProviderFactoryCreator     = dbProviderFactoryCreator;
     _configManipulator            = configManipulator;
     _globalSettings               = globalSettings;
     _connectionStrings            = connectionStrings;
     _migrationPlanExecutor        = migrationPlanExecutor;
     _databaseSchemaCreatorFactory = databaseSchemaCreatorFactory;
 }
        public DatabaseServerRegistrarAndMessengerComponent(IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerMessenger serverMessenger, IServerRegistrationService registrationService, ILogger logger, IndexRebuilder indexRebuilder)
        {
            _registrar = serverRegistrar as DatabaseServerRegistrar;
            if (_registrar == null)
            {
                throw new Exception("panic: registar.");
            }

            _messenger = serverMessenger as BatchedDatabaseServerMessenger;
            if (_messenger == null)
            {
                throw new Exception("panic: messenger");
            }

            _runtime             = runtime;
            _logger              = logger;
            _registrationService = registrationService;
            _indexRebuilder      = indexRebuilder;

            _touchTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerRegistration",
                                                                          new BackgroundTaskRunnerOptions {
                AutoStart = true
            }, logger);
            _processTaskRunner = new BackgroundTaskRunner <IBackgroundTask>("ServerInstProcess",
                                                                            new BackgroundTaskRunnerOptions {
                AutoStart = true
            }, logger);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UmbracoRouteValueTransformer"/> class.
        /// </summary>
        public UmbracoRouteValueTransformer(
            ILogger <UmbracoRouteValueTransformer> logger,
            IUmbracoContextAccessor umbracoContextAccessor,
            IPublishedRouter publishedRouter,
            IOptions <GlobalSettings> globalSettings,
            IHostingEnvironment hostingEnvironment,
            IRuntimeState runtime,
            IUmbracoRouteValuesFactory routeValuesFactory,
            IRoutableDocumentFilter routableDocumentFilter,
            IDataProtectionProvider dataProtectionProvider,
            IControllerActionSearcher controllerActionSearcher,
            IEventAggregator eventAggregator,
            IPublicAccessRequestHandler publicAccessRequestHandler)
        {
            if (globalSettings is null)
            {
                throw new ArgumentNullException(nameof(globalSettings));
            }

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
            _publishedRouter        = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter));
            _globalSettings         = globalSettings.Value;
            _hostingEnvironment     = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
            _runtime                    = runtime ?? throw new ArgumentNullException(nameof(runtime));
            _routeValuesFactory         = routeValuesFactory ?? throw new ArgumentNullException(nameof(routeValuesFactory));
            _routableDocumentFilter     = routableDocumentFilter ?? throw new ArgumentNullException(nameof(routableDocumentFilter));
            _dataProtectionProvider     = dataProtectionProvider;
            _controllerActionSearcher   = controllerActionSearcher;
            _eventAggregator            = eventAggregator;
            _publicAccessRequestHandler = publicAccessRequestHandler;
        }
        public UmbracoBackOfficeCookieAuthOptions(
            string[] explicitPaths,
            IUmbracoContextAccessor umbracoContextAccessor,
            ISecuritySection securitySection,
            IGlobalSettings globalSettings,
            IRuntimeState runtimeState,
            ISecureDataFormat <AuthenticationTicket> secureDataFormat)
        {
            var secureDataFormat1 = secureDataFormat ?? throw new ArgumentNullException(nameof(secureDataFormat));

            LoginTimeoutMinutes = globalSettings.TimeOutInMinutes;
            AuthenticationType  = Constants.Security.BackOfficeAuthenticationType;

            SlidingExpiration = true;
            ExpireTimeSpan    = TimeSpan.FromMinutes(LoginTimeoutMinutes);
            CookieDomain      = securitySection.AuthCookieDomain;
            CookieName        = securitySection.AuthCookieName;
            CookieHttpOnly    = true;
            CookieSecure      = globalSettings.UseHttps ? CookieSecureOption.Always : CookieSecureOption.SameAsRequest;
            CookiePath        = "/";

            TicketDataFormat = new UmbracoSecureDataFormat(LoginTimeoutMinutes, secureDataFormat1);

            //Custom cookie manager so we can filter requests
            CookieManager = new BackOfficeCookieManager(umbracoContextAccessor, runtimeState, globalSettings, explicitPaths);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CoreRuntime" /> class.
        /// </summary>
        public CoreRuntime(
            IRuntimeState state,
            ILoggerFactory loggerFactory,
            ComponentCollection components,
            IApplicationShutdownRegistry applicationShutdownRegistry,
            IProfilingLogger profilingLogger,
            IMainDom mainDom,
            IUmbracoDatabaseFactory databaseFactory,
            IEventAggregator eventAggregator,
            IHostingEnvironment hostingEnvironment,
            IUmbracoVersion umbracoVersion,
            IServiceProvider?serviceProvider,
            IHostApplicationLifetime?hostApplicationLifetime)
        {
            State = state;

            _loggerFactory = loggerFactory;
            _components    = components;
            _applicationShutdownRegistry = applicationShutdownRegistry;
            _profilingLogger             = profilingLogger;
            _mainDom                 = mainDom;
            _databaseFactory         = databaseFactory;
            _eventAggregator         = eventAggregator;
            _hostingEnvironment      = hostingEnvironment;
            _umbracoVersion          = umbracoVersion;
            _serviceProvider         = serviceProvider;
            _hostApplicationLifetime = hostApplicationLifetime;
            _logger = _loggerFactory.CreateLogger <CoreRuntime>();
        }
Ejemplo n.º 8
0
 public CoreRuntime(
     ILoggerFactory loggerFactory,
     IRuntimeState state,
     ComponentCollection components,
     IApplicationShutdownRegistry applicationShutdownRegistry,
     IProfilingLogger profilingLogger,
     IMainDom mainDom,
     IUmbracoDatabaseFactory databaseFactory,
     IEventAggregator eventAggregator,
     IHostingEnvironment hostingEnvironment,
     IUmbracoVersion umbracoVersion,
     IServiceProvider?serviceProvider)
     : this(
         state,
         loggerFactory,
         components,
         applicationShutdownRegistry,
         profilingLogger,
         mainDom,
         databaseFactory,
         eventAggregator,
         hostingEnvironment,
         umbracoVersion,
         serviceProvider,
         serviceProvider?.GetRequiredService <IHostApplicationLifetime>())
 {
 }
Ejemplo n.º 9
0
        /// <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);
        }
Ejemplo n.º 10
0
 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>
 /// 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>
 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;
 }
        /// <inheritdoc />
        public void Init(HttpApplication context)
        {
            try
            {
                // using the service locator here - no other way, really
                Module = Current.Factory.GetInstance <TModule>();
            }
            catch
            {
                // if GetInstance fails, it may be because of a boot error, in
                // which case that is the error we actually want to report
                IRuntimeState runtimeState = null;

                try
                {
                    runtimeState = Current.Factory.GetInstance <IRuntimeState>();
                }
                catch { /* don't make it worse */ }

                if (runtimeState?.BootFailedException != null)
                {
                    BootFailedException.Rethrow(runtimeState.BootFailedException);
                }

                // else... throw what we have
                throw;
            }

            // initialize
            Module.Init(context);
        }
Ejemplo n.º 13
0
    public UmbracoContentIndex(
        ILoggerFactory loggerFactory,
        string name,
        IOptionsMonitor <LuceneDirectoryIndexOptions> indexOptions,
        IHostingEnvironment hostingEnvironment,
        IRuntimeState runtimeState,
        ILocalizationService?languageService = null)
        : base(loggerFactory, name, indexOptions, hostingEnvironment, runtimeState)
    {
        LanguageService = languageService;
        _logger         = loggerFactory.CreateLogger <UmbracoContentIndex>();

        LuceneDirectoryIndexOptions namedOptions = indexOptions.Get(name);

        if (namedOptions == null)
        {
            throw new InvalidOperationException(
                      $"No named {typeof(LuceneDirectoryIndexOptions)} options with name {name}");
        }

        if (namedOptions.Validator is IContentValueSetValidator contentValueSetValidator)
        {
            PublishedValuesOnly = contentValueSetValidator.PublishedValuesOnly;
        }
    }
 public BackOfficeController(ManifestParser manifestParser, UmbracoFeatures features, IGlobalSettings globalSettings, UmbracoContext umbracoContext, ServiceContext services, CacheHelper applicationCache, ILogger logger, IProfilingLogger profilingLogger, IRuntimeState runtimeState)
     : base(globalSettings, umbracoContext, services, applicationCache, logger, profilingLogger)
 {
     _manifestParser = manifestParser;
     _features       = features;
     _runtimeState   = runtimeState;
 }
Ejemplo n.º 15
0
 public HttpsCheck(ILocalizedTextService textService, IRuntimeState runtime, IGlobalSettings globalSettings, IContentSection contentSection)
 {
     _textService    = textService;
     _runtime        = runtime;
     _globalSettings = globalSettings;
     _contentSection = contentSection;
 }
 public SpreakerFeed(IBackgroundTaskRunner <RecurringTaskBase> runner, int delayBeforeWeStart, int howOftenWeRepeat, IRuntimeState runtime, IProfilingLogger logger, IContentService contentService, IUmbracoContextFactory context)
     : base(runner, delayBeforeWeStart, howOftenWeRepeat)
 {
     _runtime        = runtime;
     _logger         = logger;
     _contentService = contentService;
     _context        = context;
 }
 public SpreakerFeedComponent(IProfilingLogger logger, IRuntimeState runtime, IContentService contentService, IUmbracoContextFactory context)
 {
     _context            = context;
     _logger             = logger;
     _runtime            = runtime;
     _contentService     = contentService;
     _spreakerFeedRunner = new BackgroundTaskRunner <IBackgroundTask>("SpreakerFeed", _logger);
 }
 public CustomBackgroundTask(
     IBackgroundTaskRunner <RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
     IProfilingLogger logger, IRuntimeState runtimeState)
     : base(runner, delayMilliseconds, periodMilliseconds)
 {
     this.runtimeState = runtimeState;
     this.logger       = logger;
 }
Ejemplo n.º 19
0
 /// <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)
 {
 }
Ejemplo n.º 20
0
 public ScheduledPublishing(IBackgroundTaskRunner <RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
                            IRuntimeState runtime, IContentService contentService, ILogger logger)
     : base(runner, delayMilliseconds, periodMilliseconds)
 {
     _runtime        = runtime;
     _contentService = contentService;
     _logger         = logger;
 }
 public InstallController(IUmbracoContextAccessor umbracoContextAccessor, InstallHelper installHelper, IRuntimeState runtime, ILogger logger, IGlobalSettings globalSettings)
 {
     _umbracoContextAccessor = umbracoContextAccessor;
     _installHelper          = installHelper;
     _runtime        = runtime;
     _logger         = logger;
     _globalSettings = globalSettings;
 }
 public ApplicationTreeController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor,
                                  ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger,
                                  IRuntimeState runtimeState, ITreeService treeService, ISectionService sectionService, UmbracoHelper umbracoHelper)
     : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
 {
     _treeService    = treeService;
     _sectionService = sectionService;
 }
Ejemplo n.º 23
0
 public PreviewRoutes(
     IOptions <GlobalSettings> globalSettings,
     IHostingEnvironment hostingEnvironment,
     IRuntimeState runtimeState)
 {
     _runtimeState       = runtimeState;
     _umbracoPathSegment = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);
 }
Ejemplo n.º 24
0
 public ScheduledTasks(IBackgroundTaskRunner <RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
                       IRuntimeState runtime, IUmbracoSettingsSection settings, IProfilingLogger logger)
     : base(runner, delayMilliseconds, periodMilliseconds)
 {
     _runtime  = runtime;
     _settings = settings;
     _logger   = logger;
 }
 public BackOfficeCookieManager(IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtime, IGlobalSettings globalSettings, IEnumerable <string> explicitPaths)
 {
     _umbracoContextAccessor = umbracoContextAccessor;
     _runtime                 = runtime;
     _globalSettings          = globalSettings;
     _explicitPaths           = explicitPaths?.ToArray();
     _getRemainingSecondsPath = $"{globalSettings.Path}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds";
 }
 public PublishedSnapshotServiceEventHandler(
     IRuntimeState runtime,
     IPublishedSnapshotService publishedSnapshotService,
     INuCacheContentService publishedContentService,
     IContentService contentService,
     IMediaService mediaService)
     : this(publishedSnapshotService, publishedContentService)
 {
 }
Ejemplo n.º 27
0
 internal BackOfficeServerVariables(UrlHelper urlHelper, IRuntimeState runtimeState, UmbracoFeatures features, IGlobalSettings globalSettings)
 {
     _urlHelper      = urlHelper;
     _runtimeState   = runtimeState;
     _features       = features;
     _globalSettings = globalSettings;
     _httpContext    = _urlHelper.RequestContext.HttpContext;
     _owinContext    = _httpContext.GetOwinContext();
 }
Ejemplo n.º 28
0
 public RebuildOnStartupHandler(
     ISyncBootStateAccessor syncBootStateAccessor,
     ExamineIndexRebuilder backgroundIndexRebuilder,
     IRuntimeState runtimeState)
 {
     _syncBootStateAccessor    = syncBootStateAccessor;
     _backgroundIndexRebuilder = backgroundIndexRebuilder;
     _runtimeState             = runtimeState;
 }
Ejemplo n.º 29
0
 public UmbracoMemberIndex(
     ILoggerFactory loggerFactory,
     string name,
     IOptionsMonitor <LuceneDirectoryIndexOptions> indexOptions,
     IHostingEnvironment hostingEnvironment,
     IRuntimeState runtimeState)
     : base(loggerFactory, name, indexOptions, hostingEnvironment, runtimeState)
 {
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DashboardController"/> with all its dependencies.
 /// </summary>
 public DashboardController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor,
                            ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger,
                            IRuntimeState runtimeState, IDashboardService dashboardService, UmbracoHelper umbracoHelper,
                            IContentDashboardSettings dashboardSettings)
     : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
 {
     _dashboardService  = dashboardService;
     _dashboardSettings = dashboardSettings;
 }