public async Task <string> GetSecretAsync(string secretName)
        {
            if (!_cache.ContainsKey(secretName))
            {
                _trace.Information("Cache miss for setting " + secretName);
                var secretValue = await _internalReader.GetSecretAsync(secretName);

                _cache[secretName] = secretValue;
            }

            return(_cache[secretName]);
        }
Exemple #2
0
        public async Task <string> GetSecretAsync(string secretName)
        {
            if (!_cache.ContainsKey(secretName) || IsSecretOutdated(_cache[secretName]))
            {
                // Get the secret if it is not yet in the cache or it is outdated.
                var secretValue = await _internalReader.GetSecretAsync(secretName);

                _cache[secretName] = Tuple.Create(secretValue, DateTime.UtcNow);
            }

            return(_cache[secretName].Item1);
        }
        public async Task <string> InjectAsync(string input, ILogger logger)
        {
            if (string.IsNullOrEmpty(input))
            {
                return(input);
            }

            var output      = new StringBuilder(input);
            var secretNames = GetSecretNames(input);

            foreach (var secretName in secretNames)
            {
                var secretValue = await _secretReader.GetSecretAsync(secretName, logger);

                output.Replace($"{_frame}{secretName}{_frame}", secretValue);
            }

            return(output.ToString());
        }
Exemple #4
0
 public async Task <string> GetFromManagedStorageAccountAsync(string sasDefinition)
 {
     return(await _secretReader.GetSecretAsync(sasDefinition));
 }