-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathVaultDecrypt.cs
42 lines (31 loc) · 1.34 KB
/
VaultDecrypt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Fnproject.Fn.Fdk;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Oci.KeymanagementService;
using Oci.KeymanagementService.Models;
namespace VaultDecrypt
{
class Function
{
public string function_handler(InputMessage input)
{
Dictionary<string, List<SecretContent>> output = new Dictionary<string, List<SecretContent>>();
var secret_details_list = new List<SecretContent>();
string cipher = input.cipher;
string vault_key_ocid = Environment.GetEnvironmentVariable("key_ocid");
string crypto_endpoint = Environment.GetEnvironmentVariable("cryptographic_endpoint");
KmsCryptoClient client = KmsCryptoClientHelper.GetVaultDecryptClient(crypto_endpoint);
Task<string> secret_value = GetSecretsHelper.getSecretValue(client, vault_key_ocid, cipher);
var secret_detail = new SecretContent();
secret_detail.secret_content = secret_value.Result;
secret_details_list.Add(secret_detail);
output.Add("secret_content", secret_details_list);
return System.Text.Json.JsonSerializer.Serialize(output);
}
static void Main(string[] args) { Fdk.Handle(args[0]); }
}
}