From c9fb9c0beca88b548d1169fe177ac7759d56ab82 Mon Sep 17 00:00:00 2001 From: Vitaly Bibikov Date: Mon, 22 Jul 2019 16:46:36 +0300 Subject: [PATCH] Create README.md --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..aefaf2e --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# AzureExtensions.FunctionToken +Extension Attribute to Azure Functions v2, that allows to obrain ClaimsPrincipal on every request. Currently supports key load from Azure B2C by jwks_uri and simple JsonWebKey. Pluggable on Azyre Function Startup + +The extension allows you to use custom tokens in Azure Functions v2. + +Step 1. +1. Add the nuget *AzureExtensions.FunctionToken* +2. Add to StartUp file: + +``` + + builder.AddAzureFunctionsToken(new TokenSinginingKeyOptions() + { + SigningKey = new JsonWebKey("your key"), + Audience = "your audience", + Issuer = "your issuer" + }); + +``` + +OR + +``` + builder.AddAzureFunctionsToken(new TokenAzureB2COptions() + { + //AzureB2CSingingKeyUri = new Uri("https://yourapp.b2clogin.com/yourapp.onmicrosoft.com/discovery/v2.0/keys?p=yourapp-policy"), + Audience = "your audience", + Issuer = "your issuer" + }); + +``` + +3. Add it to Azure Function: + +``` + public class Example + { + [FunctionName("Example")] + public async Task Run( + [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, + [FunctionToken] FunctionTokenResult token, + ILogger log) + { + log.LogInformation("C# HTTP trigger function processed a request."); + return (ActionResult) new OkObjectResult($"Hello, {token}"); + } + } +``` + +4. That's it. See examples for the details. +