Example #1
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();
        }
Example #2
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));
        }
Example #4
0
 public SecretManager(ISecretsRepository repository, ILogger logger, IMetricsLogger metricsLogger, HostNameProvider hostNameProvider, StartupContextProvider startupContextProvider)
     : this(repository, new DefaultKeyValueConverterFactory(repository.IsEncryptionSupported), logger, metricsLogger, hostNameProvider, startupContextProvider)
 {
 }