private static async Task <AuthTokenV01> geVer01Token(string build, string functionKey) { AuthTokenV01 auth = new AuthTokenV01(); auth.build = build; auth.header.Add("Content-Type", "text/plain"); auth.header.Add("x-functions-key", functionKey); //"iKaokUrfUCkcmAFuIxRfvgDnVDhDm6MWwJzV9H9j76dcdQSD4qzSwQ=="); return(auth); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Credentials/{myVersion}/{myFunction}/{myMethod}/{senderId}")] HttpRequest req, ILogger log, string myVersion, string myFunction, string myMethod, string senderId) { string vaultBaseUrl = System.Environment.GetEnvironmentVariable("VaultBaseUrl", EnvironmentVariableTarget.Process); string bccAccessKey = req.Headers["bcc-access-key"]; string build = "07/11/2019 14.43.00.829"; ObjectResult resp; string mode = System.Environment.GetEnvironmentVariable("Mode", EnvironmentVariableTarget.Process); try { string vaultUrl = vaultBaseUrl + @"/" + myFunction + @"/" + bccAccessKey; // +@"/ca85077d61a9444c83b55e49ef6224b5"; KeyVaultModel keyVault = new KeyVaultModel(); string functionKey = await keyVault.OnGetAsync(vaultUrl); //"iKaokUrfUCkcmAFuIxRfvgDnVDhDm6MWwJzV9H9j76dcdQSD4qzSwQ=="; // await keyVault.OnGetAsync(vaultUrl); switch (myVersion.ToLower()) { case "v0": AuthTokenV00 auth00 = await geVer00Token(build, myFunction, myMethod, mode, senderId, functionKey); resp = new OkObjectResult(auth00); break; default: AuthTokenV01 auth = await geVer01Token(build, functionKey); resp = new OkObjectResult(auth); break; } } catch (Exception e) { ErrorToken errObj = new ErrorToken(); errObj.build = build; errObj.status = 404; errObj.functionName = myFunction; errObj.message = e.Message; resp = new NotFoundObjectResult(errObj); } return(resp); }