Installation
Install AlmightyShogun.AspNet.JwtAuth in the ASP.NET Core API that needs to validate JWT access tokens and register the package's permission authorization services. The package targets net10.0, uses ASP.NET Core framework APIs, and expects an Auth configuration section to be available when authentication is registered.
sh
dotnet add package AlmightyShogun.AspNet.JwtAuthDependencies
Microsoft.AspNetCore.Appframework reference — provides the ASP.NET Core authentication, authorization, HTTP, controller, and middleware infrastructure used by the package.Microsoft.AspNetCore.Authentication.JwtBearer10.0.8— provides JWT bearer authentication middleware and token validation options.AlmightyShogun.Utilsproject reference — provides the configuration binding helper used when registeringAuthSettings.
Startup Registration
Register the package once while configuring application services. AddApiAuth also configures JWT bearer authentication, authorization services, IHttpContextAccessor, host-to-application resolution, and the dynamic permission policy provider.
WARNING
Requires an Auth section in application configuration, usually from appsettings.json.
csharp
using AlmightyShogun.AspNet.JwtAuth;
builder.Services.AddApiAuth(builder.Configuration);