Пример #1
0
        public DefaultSecretManagerProvider(IOptionsMonitor <ScriptApplicationHostOptions> options, IHostIdProvider hostIdProvider,
                                            IConfiguration configuration, IEnvironment environment, ILoggerFactory loggerFactory, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, StartupContextProvider startupContextProvider)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _options                = options ?? throw new ArgumentNullException(nameof(options));
            _hostIdProvider         = hostIdProvider ?? throw new ArgumentNullException(nameof(hostIdProvider));
            _configuration          = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _environment            = environment ?? throw new ArgumentNullException(nameof(environment));
            _hostNameProvider       = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
            _startupContextProvider = startupContextProvider ?? throw new ArgumentNullException(nameof(startupContextProvider));

            _loggerFactory     = loggerFactory;
            _metricsLogger     = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
            _secretManagerLazy = new Lazy <ISecretManager>(Create);

            // When these options change (due to specialization), we need to reset the secret manager.
            options.OnChange(_ => ResetSecretManager());
        }
        public DefaultSecretManagerProvider(IOptionsMonitor <ScriptApplicationHostOptions> options, IHostIdProvider hostIdProvider, IEnvironment environment,
                                            ILoggerFactory loggerFactory, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, StartupContextProvider startupContextProvider,
                                            IAzureBlobStorageProvider azureBlobStorageProvider)
        {
            ArgumentNullException.ThrowIfNull(loggerFactory);

            _options                = options ?? throw new ArgumentNullException(nameof(options));
            _hostIdProvider         = hostIdProvider ?? throw new ArgumentNullException(nameof(hostIdProvider));
            _environment            = environment ?? throw new ArgumentNullException(nameof(environment));
            _hostNameProvider       = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
            _startupContextProvider = startupContextProvider ?? throw new ArgumentNullException(nameof(startupContextProvider));

            _loggerFactory = loggerFactory;
            _logger        = _loggerFactory.CreateLogger <DefaultSecretManagerProvider>();

            _metricsLogger      = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
            _secretManagerLazy  = new Lazy <ISecretManager>(Create);
            _secretsEnabledLazy = new Lazy <bool>(GetSecretsEnabled);

            // When these options change (due to specialization), we need to reset the secret manager.
            options.OnChange(_ => ResetSecretManager());

            _azureBlobStorageProvider = azureBlobStorageProvider ?? throw new ArgumentNullException(nameof(azureBlobStorageProvider));
        }
 public StandbyManager(IScriptHostManager scriptHostManager, IWebHostLanguageWorkerChannelManager languageWorkerChannelManager, IConfiguration configuration, IScriptWebHostEnvironment webHostEnvironment,
                       IEnvironment environment, IOptionsMonitor <ScriptApplicationHostOptions> options, ILogger <StandbyManager> logger, HostNameProvider hostNameProvider, TimeSpan specializationTimerInterval)
 {
     _scriptHostManager               = scriptHostManager ?? throw new ArgumentNullException(nameof(scriptHostManager));
     _options                         = options ?? throw new ArgumentNullException(nameof(options));
     _logger                          = logger ?? throw new ArgumentNullException(nameof(logger));
     _specializationTask              = new Lazy <Task>(SpecializeHostCoreAsync, LazyThreadSafetyMode.ExecutionAndPublication);
     _webHostEnvironment              = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
     _environment                     = environment ?? throw new ArgumentNullException(nameof(environment));
     _configuration                   = configuration as IConfigurationRoot ?? throw new ArgumentNullException(nameof(configuration));
     _languageWorkerChannelManager    = languageWorkerChannelManager ?? throw new ArgumentNullException(nameof(languageWorkerChannelManager));
     _hostNameProvider                = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
     _changeTokenCallbackSubscription = ChangeToken.RegisterChangeCallback(_ => _logger.LogDebug($"{nameof(StandbyManager)}.{nameof(ChangeToken)} callback has fired."), null);
     _specializationTimerInterval     = specializationTimerInterval;
 }
 public StandbyManager(IScriptHostManager scriptHostManager, IWebHostLanguageWorkerChannelManager languageWorkerChannelManager, IConfiguration configuration, IScriptWebHostEnvironment webHostEnvironment,
                       IEnvironment environment, IOptionsMonitor <ScriptApplicationHostOptions> options, ILogger <StandbyManager> logger, HostNameProvider hostNameProvider)
     : this(scriptHostManager, languageWorkerChannelManager, configuration, webHostEnvironment, environment, options, logger, hostNameProvider, TimeSpan.FromMilliseconds(500))
 {
 }
Пример #5
0
        public SecretManager(ISecretsRepository repository, IKeyValueConverterFactory keyValueConverterFactory, ILogger logger, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, bool createHostSecretsIfMissing = false)
        {
            _repository = repository;
            _keyValueConverterFactory   = keyValueConverterFactory;
            _repository.SecretsChanged += OnSecretsChanged;
            _logger              = logger;
            _metricsLogger       = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
            _repositoryClassName = _repository.GetType().Name.ToLower();
            _hostNameProvider    = hostNameProvider;

            if (createHostSecretsIfMissing)
            {
                // GetHostSecrets will create host secrets if not present
                GetHostSecretsAsync().GetAwaiter().GetResult();
            }
        }
Пример #6
0
 public SecretManager(ISecretsRepository repository, ILogger logger, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, bool createHostSecretsIfMissing = false)
     : this(repository, new DefaultKeyValueConverterFactory(repository.IsEncryptionSupported), logger, metricsLogger, hostNameProvider, createHostSecretsIfMissing)
 {
 }
 public StandbyManager(IScriptHostManager scriptHostManager, IWebHostRpcWorkerChannelManager rpcWorkerChannelManager, IConfiguration configuration, IScriptWebHostEnvironment webHostEnvironment,
                       IEnvironment environment, IOptionsMonitor <ScriptApplicationHostOptions> options, ILogger <StandbyManager> logger, HostNameProvider hostNameProvider, IApplicationLifetime applicationLifetime, IMetricsLogger metricsLogger)
     : this(scriptHostManager, rpcWorkerChannelManager, configuration, webHostEnvironment, environment, options, logger, hostNameProvider, applicationLifetime, TimeSpan.FromMilliseconds(500), metricsLogger)
 {
 }
Пример #8
0
 public DefaultScriptWebHookProvider(ISecretManagerProvider secretManagerProvider, HostNameProvider hostNameProvider)
 {
     _secretManagerProvider = secretManagerProvider;
     _hostNameProvider      = hostNameProvider;
 }
Пример #9
0
        public SecretManager(ISecretsRepository repository, IKeyValueConverterFactory keyValueConverterFactory, ILogger logger, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, StartupContextProvider startupContextProvider)
        {
            _repository = repository ?? throw new ArgumentNullException(nameof(repository));
            _keyValueConverterFactory = keyValueConverterFactory ?? throw new ArgumentNullException(nameof(keyValueConverterFactory));
            _logger                 = logger ?? throw new ArgumentNullException(nameof(logger));
            _metricsLogger          = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
            _hostNameProvider       = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
            _startupContextProvider = startupContextProvider ?? throw new ArgumentNullException(nameof(startupContextProvider));

            _repositoryClassName        = _repository.GetType().Name.ToLower();
            _repository.SecretsChanged += OnSecretsChanged;

            InitializeCache();
        }
Пример #10
0
 public SecretManager(ISecretsRepository repository, ILogger logger, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, StartupContextProvider startupContextProvider)
     : this(repository, new DefaultKeyValueConverterFactory(repository.IsEncryptionSupported), logger, metricsLogger, hostNameProvider, startupContextProvider)
 {
 }
Пример #11
0
 public StandbyManager(IScriptHostManager scriptHostManager, ILanguageWorkerChannelManager languageWorkerChannelManager, IConfiguration configuration, IScriptWebHostEnvironment webHostEnvironment,
                       IEnvironment environment, IOptionsMonitor <ScriptApplicationHostOptions> options, ILogger <StandbyManager> logger, HostNameProvider hostNameProvider)
 {
     _scriptHostManager            = scriptHostManager ?? throw new ArgumentNullException(nameof(scriptHostManager));
     _options                      = options ?? throw new ArgumentNullException(nameof(options));
     _logger                       = logger ?? throw new ArgumentNullException(nameof(logger));
     _specializationTask           = new Lazy <Task>(SpecializeHostCoreAsync, LazyThreadSafetyMode.ExecutionAndPublication);
     _webHostEnvironment           = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
     _environment                  = environment ?? throw new ArgumentNullException(nameof(environment));
     _configuration                = configuration as IConfigurationRoot ?? throw new ArgumentNullException(nameof(configuration));
     _languageWorkerChannelManager = languageWorkerChannelManager ?? throw new ArgumentNullException(nameof(languageWorkerChannelManager));
     _hostNameProvider             = hostNameProvider ?? throw new ArgumentNullException(nameof(hostNameProvider));
 }