![]() |
VOOZH | about |
dotnet add package DarkLoop.Azure.Functions.Authorization.InProcess --version 4.2.1
NuGet\Install-Package DarkLoop.Azure.Functions.Authorization.InProcess -Version 4.2.1
<PackageReference Include="DarkLoop.Azure.Functions.Authorization.InProcess" Version="4.2.1" />
<PackageVersion Include="DarkLoop.Azure.Functions.Authorization.InProcess" Version="4.2.1" />Directory.Packages.props
<PackageReference Include="DarkLoop.Azure.Functions.Authorization.InProcess" />Project file
paket add DarkLoop.Azure.Functions.Authorization.InProcess --version 4.2.1
#r "nuget: DarkLoop.Azure.Functions.Authorization.InProcess, 4.2.1"
#:package DarkLoop.Azure.Functions.Authorization.InProcess@4.2.1
#addin nuget:?package=DarkLoop.Azure.Functions.Authorization.InProcess&version=4.2.1Install as a Cake Addin
#tool nuget:?package=DarkLoop.Azure.Functions.Authorization.InProcess&version=4.2.1Install as a Cake Tool
Bringing AuthorizeAttribute Behavior to Azure Functions v3 and v4 (In-Process)
It hooks into .NET Core dependency injection container to enable authentication and authorization in the same way ASP.NET Core does.
Breaking for current package consumers
Starting with version 4.1.0, due to security changes made on the Functions runtime, the Bearer scheme is no longer supported for your app functions.
Use
AddJwtFunctionsBearer(Action<JwtBearerOptions>)instead ofAddJwtBearer(Action<JwtBearerOptions>)when setting up authentication. UsingAddJwtBearerwill generate a compilation error when used againstFunctionsAuthenticationBuilder. We are introducingJwtFunctionsBearerDefaultsto refer to the suggested new custom scheme name.No changes should be required if already using a custom scheme name.
dotnet add package DarkLoop.Azure.Functions.Authorize
The goal is to utilize the same authentication framework provided for ASP.NET Core
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using MyFunctionAppNamespace;
[assembly: FunctionsStartup(typeof(Startup))]
namespace MyFunctionAppNamespace
{
class Startup : FunctionsStartup
{
public void Configure(IFunctionsHostBuilder builder)
{
builder
.AddAuthentication(options =>
{
options.DefaultAuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddOpenIdConnect(options =>
{
options.ClientId = "<my-client-id>";
// ... more options here
})
// This is important as Bearer scheme is used by the runtime
// and no longer supported by this framework.
.AddJwtFunctionsBearer(options =>
{
options.Audience = "<my-audience>";
// ... more options here
});
builder
.AddAuthorization(options =>
{
options.AddPolicy("OnlyAdmins", policyBuilder =>
{
// configure my policy requirements
});
});
}
}
}
Starting with version 4.1.0, the default Bearer scheme is not supported by this framework. You can use a custom scheme or make use of
AddJwtFunctionsBearer(Action<JwtBearerOptions>)as shown above. This one adds the"FunctionsBearer"scheme. Clients still submit token for Authorization header in the format:Bearer <token>.
No need to register the middleware the way we do for ASP.NET Core applications.
And now lets use FunctionAuthorizeAttribute the same way we use AuthorizeAttribute in our ASP.NET Core applications.
public class Functions
{
[FunctionAuthorize]
[FunctionName("get-record")]
public async Task<IActionResult> GetRecord(
[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
ILogger log)
{
var user = req.HttpContext.User;
var record = GetUserData(user.Identity.Name);
return new OkObjectResult(record);
}
[FunctionAuthorize(Policy = "OnlyAdmins")]
[FunctionName("get-all-records")]
public async Task<IActionResult> GetAllRecords(
[HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
ILogger log)
{
var records = GetAllData();
return new OkObjectResult(records);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.1 | 331 | 10/23/2025 |
| 4.2.1-preview-251022-1 | 250 | 10/22/2025 |
| 4.2.0 | 4,906 | 1/28/2025 |
| 4.2.0-preview-250128-7 | 219 | 1/28/2025 |
| 4.2.0-preview-250128-5 | 200 | 1/28/2025 |
| 4.2.0-preview-250128-3 | 182 | 1/28/2025 |
| 4.1.3 | 477 | 11/22/2024 |
| 4.1.3-preview-241121-5 | 187 | 11/21/2024 |
| 4.1.2 | 8,063 | 8/20/2024 |
| 4.1.2-preview-240819-12 | 232 | 8/19/2024 |
| 4.1.2-preview-240818-2 | 245 | 8/18/2024 |
| 4.1.1 | 256 | 8/17/2024 |
| 4.1.1-preview-240816-18 | 253 | 8/16/2024 |
| 4.1.1-preview-240719-1 | 223 | 7/19/2024 |
| 4.1.0 | 506 | 5/27/2024 |
| 4.1.0-preview-240522-2 | 240 | 5/22/2024 |
| 4.1.0-preview-240522-1 | 230 | 5/22/2024 |
| 4.1.0-preview-240521-1 | 224 | 5/21/2024 |
| 4.0.1 | 7,892 | 3/19/2024 |