I'm trying to work out how to configure logging Authentication events that occur is MicrosoftIdentityWeb in ASP.NET Core 6.0 and I'm having trouble finding a simple example.
My code is currently the .net60 template code, I've tried to follow previous examples to add logging, but I can't get it to work correctly:
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Identity.Web;
var builder = WebApplication.CreateBuilder(args);
IConfiguration opt = builder.Configuration.GetSection("AzureAd");
// Add services to the container.
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
// Was: .AddMicrosoftIdentityWebApi(Configuration);
.AddMicrosoftIdentityWebApi(options =>
{
// Handle Auth events and bind Configuration here somehow?
});
...
How can I bind the configuration and subscribe to the authentication events so I can see why my authentication is failing and log auth attempts for security purposes?