Exemple #1
0
        internal static void DownloadAppSettings()
        {
            var xml = XDocument.Load(SecretsProvider.WebconfigFile);
            var doc = xml.Element("configuration");


            var appSettings = doc.Element("appSettings");

            if (appSettings == null)
            {
                doc.Add(XElement.Parse("<appSettings></appSettings>"));
                appSettings = doc.Element("appSettings");
            }

            appSettings.Elements().Remove();

            var tasks = new List <Task <bool> >();

            foreach (var key in ConfigurationManager.AppSettings.AllKeys)
            {
                tasks.Add(Task.Run(async() => await KeyVaultProvider.DeleteSecretAsync(key)));
                var secret = ConfigurationManager.AppSettings[key];
                appSettings.Add(XElement.Parse($"<add key=\"{key}\" value=\"{secret}\" />"));
            }

            xml.Save(SecretsProvider.WebconfigFile);

            var results = Task.WhenAll(tasks).Result;

            if (results.Any(x => !x))
            {
                throw new KeyMasterException("Key Master couldn't delete all secrets from azure");
            }
        }
Exemple #2
0
        internal static bool DeleteAppSetting(Secrets secrets, string key)
        {
            var appsettings = new AppSettings
            {
                ClientId     = secrets.ClientId,
                ClientSecret = secrets.ClientSecret,
                DirectoryId  = secrets.DirectoryId,
                SecretName   = secrets.SecretName,
                KeyVaultUrl  = secrets.KeyVaultUrl
            };


            return(KeyVaultProvider.DeleteSecretAsync(key, appsettings).Result);
        }