FrodeHus.Azure.FunctionsNETWorker.Authentication
1.0.0
.NET 5.0
dotnet add package FrodeHus.Azure.FunctionsNETWorker.Authentication --version 1.0.0
NuGet\Install-Package FrodeHus.Azure.FunctionsNETWorker.Authentication -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FrodeHus.Azure.FunctionsNETWorker.Authentication" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FrodeHus.Azure.FunctionsNETWorker.Authentication --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FrodeHus.Azure.FunctionsNETWorker.Authentication, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FrodeHus.Azure.FunctionsNETWorker.Authentication as a Cake Addin
#addin nuget:?package=FrodeHus.Azure.FunctionsNETWorker.Authentication&version=1.0.0
// Install FrodeHus.Azure.FunctionsNETWorker.Authentication as a Cake Tool
#tool nuget:?package=FrodeHus.Azure.FunctionsNETWorker.Authentication&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sample configuration
The middleware expects Azure AD configuration in the form of:
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "your tenant id",
"ClientId": "your application id"
}
}
public static void Main()
{
var host = new HostBuilder()
.ConfigureAppConfiguration(c =>
{
c.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
c.Build();
})
.ConfigureServices((b, s) =>
{
s.AddOptions();
s.Configure<AzureAdConfig>(b.Configuration.GetSection("AzureAd"));
})
.ConfigureFunctionsWorkerDefaults(app => app.UseMiddleware<AuthenticationMiddleware>())
.Build();
host.Run();
}
To verify authorization, you can tag your functions with [RequireRoles("User,Admin")]
and then call the extension method FunctionContext.VerifyUserRoles()
like in this example:
[Function("SecureFunc")]
[RequireRole("Access.Basic")]
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req,
FunctionContext executionContext)
{
if (!executionContext.VerifyUserRoles())
{
return req.CreateResponse(HttpStatusCode.Forbidden);
}
var response = req.CreateResponse(HttpStatusCode.OK);
return response;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. 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. |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Microsoft.Azure.Functions.Worker (>= 1.0.0)
- Microsoft.Identity.Web (>= 1.8.2)
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 |
---|---|---|
1.0.0 | 275 | 3/25/2021 |