public static IConfigurationBuilder AddHashiCorpVault(
            this IConfigurationBuilder configurationBuilder,
            IHashiCorpVaultClient client,
            string prefix,
            IEnumerable <string> secrets)
        {
            if (configurationBuilder == null)
            {
                throw new ArgumentNullException(nameof(configurationBuilder));
            }

            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (secrets == null)
            {
                throw new ArgumentNullException(nameof(secrets));
            }

            configurationBuilder.Add(new HashiCorpVaultConfigurationSource()
            {
                Client  = client,
                Prefix  = prefix,
                Secrets = secrets
            });

            return(configurationBuilder);
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of <see cref="HashiCorpVaultConfigurationProvider"/>
 /// </summary>
 /// <param name="client">The <see cref="IHashiCorpVaultClient"/>to use for retrieving values</param>
 /// <param name="keyPrefix"> Prefix for the HashiCorp Vault ie "secrets/mykey_prefix/" or "secret/gourp2/" or "secret/group1/keyC""
 /// </param>
 /// <param name="secrets"> Keys in the HashiCorp Vault keyA, keyB etc. </param>
 public HashiCorpVaultConfigurationProvider(IHashiCorpVaultClient client, string keyPrefix, IEnumerable <string> secrets)
 {
     if (keyPrefix == null)
     {
         throw new ArgumentNullException(nameof(keyPrefix));
     }
     _client     = client ?? throw new ArgumentNullException(nameof(client));
     _basePrefix = GetBasePath(keyPrefix);
     _secrets    = secrets ?? throw new ArgumentNullException(nameof(secrets));
 }
 public HashiCorpConfigurationProvider(IHashiCorpVaultClient client, string keyPrefix, IEnumerable <string> secrets)
 {
     _client   = client;
     _basePath = GetBasePath(keyPrefix);
     _secrets  = secrets;
 }