AddJwtBearerAuthentication
Adds JWT bearer authentication to an existing AuthenticationBuilder by reading the package's Auth configuration section. The method configures issuer validation, token lifetime validation, signing-key validation, and the symmetric signing key from AuthSettings.Secret.
After the JWT has passed the normal bearer-token validation, the package resolves the current request host to an application name and verifies that the token audience contains that application. This is useful when the same authentication setup is shared by multiple apps or hosts, but tokens must still be scoped to the app they are used against.
Usage
WARNING
Requires an Auth section in application configuration, usually from appsettings.json.
using AlmightyShogun.AspNet.JwtAuth;
using Microsoft.AspNetCore.Authentication.JwtBearer;
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearerAuthentication(builder.Configuration);Parameters
configuration: IConfiguration
Application configuration containing the Auth section.
Returns
TheAuthenticationBuilder instance with JWT bearer authentication configured.Type signature
public AuthenticationBuilder AddJwtBearerAuthentication(
IConfiguration configuration
);