示例#1
0
        private static async Task <AuthTokenV00> geVer00Token(string build, string myFunction, string myMethod, string mode, string senderId, string functionKey)
        {
            AuthTokenV00 auth = new AuthTokenV00();

            auth.build = build;
            auth.header.Add("Content-Type", "text/plain");
            auth.header.Add("x-functions-key", functionKey);  // "iKaokUrfUCkcmAFuIxRfvgDnVDhDm6MWwJzV9H9j76dcdQSD4qzSwQ==");
            auth.url = "https://" + myFunction + ".azurewebsites.net/api/" + myMethod + "/" + mode + "/" + senderId + "/121/csv";

            return(auth);
        }
示例#2
0
        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);
        }