Ejemplo n.º 1
0
        private async Task <string> GetSecretAsync(KeyVaultModel model)
        {
            var client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetAccessTokenAsync), HTTP);
            var secret = await client.GetSecretAsync(model.Url, model.Key);

            return(secret.Value);
        }
Ejemplo n.º 2
0
        public IActionResult Index(KeyVaultModel model)
        {
            Request.Headers.Add("X-WI-ApplicationID", model.ApplicationID);
            Request.Headers.Add("X-WI-ClientSecret", model.ClientSecret);

            // Apply input history from cookie
            var cu = ControllerUtils.From(this);

            cu.PersistInput("Url", model, KeyVaultModel.Default.Url);
            cu.PersistInput("ApplicationID", model, KeyVaultModel.Default.ApplicationID);
            cu.PersistInput("ClientSecret", model, KeyVaultModel.Default.ClientSecret);
            cu.PersistInput("Key", model, KeyVaultModel.Default.Key);

            if (!model.SkipRequest)
            {
                try
                {
                    model.Value = GetSecretAsync(model).ConfigureAwait(false).GetAwaiter().GetResult();
                }
                catch (Exception ex)
                {
                    model.ErrorMessage = ex.Message;
                }
            }
            model.SkipRequest = false;

            return(View(model));
        }
        public IActionResult Index()
        {
            KeyVaultModel keyVaultModel = new KeyVaultModel();

            keyVaultModel.ConnectionStringKeyVault = _configuration["DBConnectionStringKF"];
            keyVaultModel.TokenKeyVault            = _configuration["TokenAppKF"];

            return(View(keyVaultModel));
        }
Ejemplo n.º 4
0
        private void BuildOptions()
        {
            var builder = KeyVaultOptionsBuilder.New();
            var options = new TOptions();

            options.Configure(builder);
            LoadResourceConfiguration(builder);
            _keyVaultModel = builder.Build();
        }
        public string UpdateSecret([FromBody] MyKeySecrets item)
        {
            KeyVaultModel kv   = new KeyVaultModel();
            Task          task = Task.Run(() =>
            {
                kv.UpdateSecret(item.SecretName, item.SecretContent);
            });

            return("{ \"status\": \"OK\" }");
        }
        public string GetToken(string secretName)
        {
            KeyVaultModel kv   = new KeyVaultModel();
            Task <string> task = Task.Run(async() =>
            {
                return(await kv.GetSecret(secretName));
            });

            return(task.Result);
        }