示例#1
0
        private static async Task CreateMultipleVersionsOfSecret(KeyVaultHelpers kv, string secretName)
        {
            foreach (var i in Enumerable.Range(1, 3))
            {
                var value = DateTime.UtcNow.Ticks;
                await kv.CreateSecret(secretName, value.ToString());

                await Task.Delay(500);
            }
        }
示例#2
0
        public async Task Run()
        {
            var authHelper = new AuthToKeyVault();
            var kv         = new KeyVaultHelpers(KeyVaultUrl, authHelper.AuthenticateToKeyVault);

            await ListAllKeys(kv);
            await ListAllSecrets(kv);

            const string multipleVersionTest = "multiple-secret-version-test";
            //await CreateMultipleVersionsOfSecret(kv, multipleVersionTest);
            //await ListAllSecretVersions(kv, multipleVersionTest);

            var latest = await kv.GetSecret(multipleVersionTest);

            Console.WriteLine("Latest of multiple versions is:");
            Output(latest);
        }
示例#3
0
        private static async Task ListAllKeyVersions(KeyVaultHelpers kv, string keyName)
        {
            var keyVersionPages = await kv.GetKeyVersions(keyName);

            foreach (var keyVersion in keyVersionPages)
            {
                Output(keyVersion);

                var vid        = keyVersion.Identifier;
                var vidVersion = vid.Version;

                if (keyVersion.Attributes.Enabled == true)
                {
                    var keyBundle = await kv.GetKey(keyName, vidVersion);

                    Output(keyBundle);
                }
            }
        }
示例#4
0
        private static async Task ListAllSecretVersions(KeyVaultHelpers kv, string secretName)
        {
            var secretVersionPages = await kv.GetSecretVersions(secretName);

            foreach (var secretVersion in secretVersionPages)
            {
                Output(secretVersion);

                var vid        = secretVersion.Identifier;
                var vidVersion = vid.Version;

                if (secretVersion.Attributes.Enabled == true)
                {
                    var secretBundle = await kv.GetSecret(secretName, vidVersion);

                    Output(secretBundle);
                }
            }
        }
示例#5
0
        private static async Task ListAllSecrets(KeyVaultHelpers kv)
        {
            var secretPages = await kv.GetSecrets();

            foreach (var secretItem in secretPages)
            {
                Console.WriteLine();

                Output(secretItem);

                var secretName = secretItem.Identifier.Name;

                if (secretItem.Attributes.Enabled == true)
                {
                    var secretBundle = await kv.GetSecret(secretName);

                    Output(secretBundle);
                }

                await ListAllSecretVersions(kv, secretName);
            }
        }
示例#6
0
        private static async Task ListAllKeys(KeyVaultHelpers kv)
        {
            var keyPages = await kv.GetKeys();

            foreach (var keyItem in keyPages)
            {
                Console.WriteLine();

                Output(keyItem);

                var keyName = keyItem.Identifier.Name;

                if (keyItem.Attributes.Enabled == true)
                {
                    var keyBundle = await kv.GetKey(keyName);

                    Output(keyBundle);
                }

                await ListAllKeyVersions(kv, keyName);
            }
        }