Reputation: 11
I'm using NSwag library and AzureAD for authentication and want to exclude the swagger UI from asp.net core authentication entirely, similar to using the AllowAnonymous attribute on the controller.
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(adSection);
builder.Services.AddAuthorization(options =>
{
// By default, all incoming requests will be authorized according to
// the default policy
options.FallbackPolicy = options.DefaultPolicy;
});
Upvotes: 0
Views: 29
Reputation: 11621
move swagger related middlewares
app.UseOpenApi();
app.UseSwaggerUi();
before app.UseAuthorization();
Upvotes: 0