AzureFunctions.Authentication
4.0.0
See the version list below for details.
dotnet add package AzureFunctions.Authentication --version 4.0.0
NuGet\Install-Package AzureFunctions.Authentication -Version 4.0.0
<PackageReference Include="AzureFunctions.Authentication" Version="4.0.0" />
paket add AzureFunctions.Authentication --version 4.0.0
#r "nuget: AzureFunctions.Authentication, 4.0.0"
// Install AzureFunctions.Authentication as a Cake Addin #addin nuget:?package=AzureFunctions.Authentication&version=4.0.0 // Install AzureFunctions.Authentication as a Cake Tool #tool nuget:?package=AzureFunctions.Authentication&version=4.0.0
azure-functions-authentication
Provides Azure Functions v3 friendly ASP.NET Core Authentication/Authorization
Problem
Azure Function v3 have ability to use Startup.cs class with Dependecy Injection same as ASP.NET Core applications, it is not working as expected out of the box though. The reason for that is default/internal (admin) features of Azure Functions Web Host that are protected with the exact same ASP.NET Core Authentication/Authorization registrations which will be overriden once you register yours and you'll start seeing such problem in Azure Portal . Moreover, predefined Azure Functions "AuthorizationLevel" policies wont work neither.
Root cause of a problem
Please read this issue to get more context: https://github.com/Azure/azure-functions-host/issues/6805.
Workaround
Register ASP.NET Core Authentication/Authorization in such a way that it is not replacing nor dropping existing configurations/schemas/handlers but extend it instead. This is achieved with "Dynamic schema registration", see example here: https://github.com/aspnet/AuthSamples/tree/master/samples/DynamicSchemes.
Solution
- Expose custom Authentication/Authorization builder extensions that dont override existing one but registers all needed services
- Provide custom extension that derives from "IExtensionConfigProvider"
- Re-configure already configured Authentication/Authorization by Azure Functions
- Dynamically inject new authentication schema and handler since "Bearer" schema is used by Azure Functions with their handler
- Override "IAuthorizationHandlerProvider" to merge Azure Functions handlers with application handlers
Example
- Add/replace existing AddAuthentication/AddAuthorization extension methods to AddFunctionAuthentication/AddFunctionAuthorization
- Register "IAuthorizationHandler" handlers
- Inject all needed services "IAuthenticationSchemeProvider/IAuthorizationPolicyProvider/IPolicyEvaluator" to authenticate & authorize request inside function. Alternative, encourage you to try nice package out there to simplify this process https://www.nuget.org/packages/DarkLoop.Azure.Functions.Authorize
- Enjoy 😄
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Azure.WebJobs.Extensions.Http (>= 3.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.0.1 | 1,363 | 6/6/2024 |
6.0.0 | 139 | 6/4/2024 |
4.1.0 | 11,398 | 5/25/2023 |
4.0.7.3 | 161 | 5/25/2023 |
4.0.7.2 | 142 | 5/25/2023 |
4.0.7.1 | 154 | 5/25/2023 |
4.0.7 | 6,895 | 2/23/2023 |
4.0.6 | 1,055 | 1/24/2023 |
4.0.5 | 3,841 | 5/21/2022 |
4.0.3 | 489 | 4/27/2022 |
4.0.2 | 449 | 4/23/2022 |
4.0.1 | 446 | 4/22/2022 |
4.0.0 | 567 | 4/22/2022 |
1.0.6 | 5,230 | 9/2/2021 |
1.0.5 | 353 | 9/2/2021 |
1.0.4 | 339 | 8/31/2021 |
1.0.3 | 360 | 8/23/2021 |
1.0.2 | 319 | 8/23/2021 |
1.0.1 | 334 | 8/23/2021 |
1.0.0 | 362 | 8/23/2021 |
- Added support of Azure Function V4