From 4d3de8fb7c129ddc900dd96493bd12b680bb05af Mon Sep 17 00:00:00 2001 From: "Daniel Mackay [SSW]" <2636640+danielmackay@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:27:47 +1000 Subject: [PATCH] Add auth back in --- src/WebUI/Program.cs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/WebUI/Program.cs b/src/WebUI/Program.cs index ec55875..3602f9a 100644 --- a/src/WebUI/Program.cs +++ b/src/WebUI/Program.cs @@ -12,22 +12,21 @@ var initialScopes = builder.Configuration.GetSection("DownstreamApi:Scopes").Get(); -// TODO: Add auth back in -// builder.Services -// .AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) -// .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) -// .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) -// .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) -// // TODO: Consider switching to session cache to make development easier -// // .AddDistributedTokenCaches() -// // .AddSessionTokenCaches(); -// .AddInMemoryTokenCaches(); -// -// builder.Services.AddAuthorization(options => -// { -// // By default, all incoming requests will be authorized according to the default policy. -// options.FallbackPolicy = options.DefaultPolicy; -// }); +builder.Services + .AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) + .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) + .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) + .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) + // TODO: Consider switching to session cache to make development easier + // .AddDistributedTokenCaches() + // .AddSessionTokenCaches(); + .AddInMemoryTokenCaches(); + +builder.Services.AddAuthorization(options => +{ + // By default, all incoming requests will be authorized according to the default policy. + options.FallbackPolicy = options.DefaultPolicy; +}); builder.Services.AddDistributedMemoryCache();