Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybibikov authored Jul 22, 2019
1 parent 9259d08 commit c9fb9c0
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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<IActionResult> 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.

0 comments on commit c9fb9c0

Please sign in to comment.