diff --git a/IdentityServer/v7/DPoP/Api/Api.csproj b/IdentityServer/v7/DPoP/Api/Api.csproj index a4e387c0..8adec631 100644 --- a/IdentityServer/v7/DPoP/Api/Api.csproj +++ b/IdentityServer/v7/DPoP/Api/Api.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v7/DPoP/Api/Program.cs b/IdentityServer/v7/DPoP/Api/Program.cs index 57f9bfe3..4fb3341d 100644 --- a/IdentityServer/v7/DPoP/Api/Program.cs +++ b/IdentityServer/v7/DPoP/Api/Program.cs @@ -2,20 +2,12 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using Duende.AspNetCore.Authentication.JwtBearer.DPoP; -using Serilog; -using Serilog.Sinks.SystemConsole.Themes; Console.Title = "API"; -Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code) - .CreateLogger(); - var builder = WebApplication.CreateBuilder(args); -builder.Services.AddSerilog(); +builder.AddServiceDefaults(); builder.Services.AddControllers(); builder.Services.AddCors(); @@ -54,6 +46,7 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); diff --git a/IdentityServer/v7/DPoP/ClientCredentials/Program.cs b/IdentityServer/v7/DPoP/ClientCredentials/Program.cs index f3033a9f..60fd2748 100644 --- a/IdentityServer/v7/DPoP/ClientCredentials/Program.cs +++ b/IdentityServer/v7/DPoP/ClientCredentials/Program.cs @@ -9,8 +9,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Tokens; -using Serilog; -using Serilog.Sinks.SystemConsole.Themes; namespace ClientCredentials; @@ -20,18 +18,12 @@ public static void Main(string[] args) { Console.Title = "Client"; - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .WriteTo.Console(theme: AnsiConsoleTheme.Code) - .CreateLogger(); - CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) { var host = Host.CreateDefaultBuilder(args) - .UseSerilog() .ConfigureServices((services) => { diff --git a/IdentityServer/v7/DPoP/DPoP.AppHost/AppHost.cs b/IdentityServer/v7/DPoP/DPoP.AppHost/AppHost.cs new file mode 100644 index 00000000..855bba91 --- /dev/null +++ b/IdentityServer/v7/DPoP/DPoP.AppHost/AppHost.cs @@ -0,0 +1,15 @@ +var builder = DistributedApplication.CreateBuilder(args); + +var idp = builder.AddProject("identityserverhost"); + +var api = builder.AddProject("api"); + +builder.AddProject("webclient") + .WaitFor(idp) + .WaitFor(api); + +builder.AddProject("clientcredentials") + .WaitFor(idp) + .WaitFor(api); + +builder.Build().Run(); diff --git a/IdentityServer/v7/DPoP/DPoP.AppHost/DPoP.AppHost.csproj b/IdentityServer/v7/DPoP/DPoP.AppHost/DPoP.AppHost.csproj new file mode 100644 index 00000000..fcbf3b3b --- /dev/null +++ b/IdentityServer/v7/DPoP/DPoP.AppHost/DPoP.AppHost.csproj @@ -0,0 +1,21 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + + + diff --git a/IdentityServer/v7/DPoP/DPoP.AppHost/Properties/launchSettings.json b/IdentityServer/v7/DPoP/DPoP.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..3e3fd3b4 --- /dev/null +++ b/IdentityServer/v7/DPoP/DPoP.AppHost/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:17007;http://localhost:15007", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21007", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23007", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22007" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15007", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19007", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18007", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20007" + } + } + } +} diff --git a/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.Development.json b/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.Development.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.json b/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v7/DPoP/DPoP.sln b/IdentityServer/v7/DPoP/DPoP.sln index 8af1c263..69dc74c8 100644 --- a/IdentityServer/v7/DPoP/DPoP.sln +++ b/IdentityServer/v7/DPoP/DPoP.sln @@ -11,28 +11,78 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebClient", "WebClient\WebC EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServerHost", "..\IdentityServerHost\src\IdentityServerHost.csproj", "{60375429-8C38-4A49-BCBF-1AD486D33EDC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DPoP.AppHost", "DPoP.AppHost\DPoP.AppHost.csproj", "{4215C502-1889-4B92-B3BC-C6DB63FF4CF0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x64.ActiveCfg = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x64.Build.0 = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x86.ActiveCfg = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x86.Build.0 = Debug|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|Any CPU.Build.0 = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x64.ActiveCfg = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x64.Build.0 = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x86.ActiveCfg = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x86.Build.0 = Release|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x64.ActiveCfg = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x64.Build.0 = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x86.Build.0 = Debug|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|Any CPU.Build.0 = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x64.ActiveCfg = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x64.Build.0 = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x86.ActiveCfg = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x86.Build.0 = Release|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x64.ActiveCfg = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x64.Build.0 = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x86.ActiveCfg = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x86.Build.0 = Debug|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|Any CPU.Build.0 = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x64.ActiveCfg = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x64.Build.0 = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x86.ActiveCfg = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x86.Build.0 = Release|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x64.ActiveCfg = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x64.Build.0 = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x86.ActiveCfg = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x86.Build.0 = Debug|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|Any CPU.Build.0 = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x64.ActiveCfg = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x64.Build.0 = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x86.ActiveCfg = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x86.Build.0 = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|x64.ActiveCfg = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|x64.Build.0 = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|x86.ActiveCfg = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Debug|x86.Build.0 = Debug|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|Any CPU.Build.0 = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|x64.ActiveCfg = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|x64.Build.0 = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|x86.ActiveCfg = Release|Any CPU + {4215C502-1889-4B92-B3BC-C6DB63FF4CF0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/IdentityServer/v7/DPoP/WebClient/Program.cs b/IdentityServer/v7/DPoP/WebClient/Program.cs index cd0080f7..65423fb6 100644 --- a/IdentityServer/v7/DPoP/WebClient/Program.cs +++ b/IdentityServer/v7/DPoP/WebClient/Program.cs @@ -7,19 +7,12 @@ using Duende.AccessTokenManagement.OpenIdConnect; using Microsoft.AspNetCore.Authentication; using Microsoft.IdentityModel.Tokens; -using Serilog; Console.Title = "WebClient"; -Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}") - .CreateLogger(); - var builder = WebApplication.CreateBuilder(args); -builder.Services.AddSerilog(); +builder.AddServiceDefaults(); builder.Services.AddControllersWithViews(); // add cookie-based session management with OpenID Connect authentication @@ -94,6 +87,7 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); app.UseStaticFiles(); diff --git a/IdentityServer/v7/DPoP/WebClient/WebClient.csproj b/IdentityServer/v7/DPoP/WebClient/WebClient.csproj index cf9d37d9..076d07ff 100644 --- a/IdentityServer/v7/DPoP/WebClient/WebClient.csproj +++ b/IdentityServer/v7/DPoP/WebClient/WebClient.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v7/IdentityServerHost/src/HostingExtensions.cs b/IdentityServer/v7/IdentityServerHost/src/HostingExtensions.cs index 5a831160..aea9d187 100644 --- a/IdentityServer/v7/IdentityServerHost/src/HostingExtensions.cs +++ b/IdentityServer/v7/IdentityServerHost/src/HostingExtensions.cs @@ -4,21 +4,16 @@ using Duende.IdentityServer; using IdentityServerHost; using Microsoft.AspNetCore.DataProtection; -using Serilog; internal static class HostingExtensions { public static WebApplication ConfigureServices(this WebApplicationBuilder builder) { + builder.AddServiceDefaults(); builder.Services.AddRazorPages(); var idsvrBuilder = builder.Services.AddIdentityServer(options => { - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - // see https://docs.duendesoftware.com/identityserver/fundamentals/resources/api-scopes options.EmitStaticAudienceClaim = true; options.PushedAuthorization.AllowUnregisteredPushedRedirectUris = true; @@ -64,7 +59,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde public static WebApplication ConfigurePipeline(this WebApplication app) { - app.UseSerilogRequestLogging(); + app.MapDefaultEndpoints(); if (app.Environment.IsDevelopment()) { diff --git a/IdentityServer/v7/IdentityServerHost/src/IdentityServerHost.csproj b/IdentityServer/v7/IdentityServerHost/src/IdentityServerHost.csproj index 7ff6b6d4..6bc34ace 100755 --- a/IdentityServer/v7/IdentityServerHost/src/IdentityServerHost.csproj +++ b/IdentityServer/v7/IdentityServerHost/src/IdentityServerHost.csproj @@ -7,7 +7,10 @@ - + + + + diff --git a/IdentityServer/v7/IdentityServerHost/src/Program.cs b/IdentityServer/v7/IdentityServerHost/src/Program.cs index c25e5e99..f2828065 100755 --- a/IdentityServer/v7/IdentityServerHost/src/Program.cs +++ b/IdentityServer/v7/IdentityServerHost/src/Program.cs @@ -1,41 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -using Serilog; -using Serilog.Events; -using Serilog.Sinks.SystemConsole.Themes; +var builder = WebApplication.CreateBuilder(args); -Log.Logger = new LoggerConfiguration() - .WriteTo.Console() - .CreateBootstrapLogger(); +var app = builder + .ConfigureServices() + .ConfigurePipeline(); -Log.Information("Starting up"); - -try -{ - var builder = WebApplication.CreateBuilder(args); - - builder.Host.UseSerilog((ctx, lc) => lc - .MinimumLevel.Debug() - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) - .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information) - .MinimumLevel.Override("System", LogEventLevel.Warning) - .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)); - - var app = builder - .ConfigureServices() - .ConfigurePipeline(); - - app.Run(); -} -catch (Exception ex) -{ - Log.Fatal(ex, "Unhandled exception"); -} -finally -{ - Log.Information("Shut down complete"); - Log.CloseAndFlush(); -} +app.Run(); diff --git a/IdentityServer/v8/DPoP/Api/Api.csproj b/IdentityServer/v8/DPoP/Api/Api.csproj index a4e387c0..8adec631 100644 --- a/IdentityServer/v8/DPoP/Api/Api.csproj +++ b/IdentityServer/v8/DPoP/Api/Api.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v8/DPoP/Api/Program.cs b/IdentityServer/v8/DPoP/Api/Program.cs index 012302a9..99725337 100644 --- a/IdentityServer/v8/DPoP/Api/Program.cs +++ b/IdentityServer/v8/DPoP/Api/Program.cs @@ -2,20 +2,12 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using Duende.AspNetCore.Authentication.JwtBearer.DPoP; -using Serilog; -using Serilog.Sinks.SystemConsole.Themes; Console.Title = "API"; -Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code) - .CreateLogger(); - var builder = WebApplication.CreateBuilder(args); -builder.Services.AddSerilog(); +builder.AddServiceDefaults(); builder.Services.AddControllers(); builder.Services.AddCors(); @@ -55,6 +47,7 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); diff --git a/IdentityServer/v8/DPoP/ClientCredentials/Program.cs b/IdentityServer/v8/DPoP/ClientCredentials/Program.cs index f3033a9f..60fd2748 100644 --- a/IdentityServer/v8/DPoP/ClientCredentials/Program.cs +++ b/IdentityServer/v8/DPoP/ClientCredentials/Program.cs @@ -9,8 +9,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Tokens; -using Serilog; -using Serilog.Sinks.SystemConsole.Themes; namespace ClientCredentials; @@ -20,18 +18,12 @@ public static void Main(string[] args) { Console.Title = "Client"; - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .WriteTo.Console(theme: AnsiConsoleTheme.Code) - .CreateLogger(); - CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) { var host = Host.CreateDefaultBuilder(args) - .UseSerilog() .ConfigureServices((services) => { diff --git a/IdentityServer/v8/DPoP/DPoP.AppHost/AppHost.cs b/IdentityServer/v8/DPoP/DPoP.AppHost/AppHost.cs new file mode 100644 index 00000000..855bba91 --- /dev/null +++ b/IdentityServer/v8/DPoP/DPoP.AppHost/AppHost.cs @@ -0,0 +1,15 @@ +var builder = DistributedApplication.CreateBuilder(args); + +var idp = builder.AddProject("identityserverhost"); + +var api = builder.AddProject("api"); + +builder.AddProject("webclient") + .WaitFor(idp) + .WaitFor(api); + +builder.AddProject("clientcredentials") + .WaitFor(idp) + .WaitFor(api); + +builder.Build().Run(); diff --git a/IdentityServer/v8/DPoP/DPoP.AppHost/DPoP.AppHost.csproj b/IdentityServer/v8/DPoP/DPoP.AppHost/DPoP.AppHost.csproj new file mode 100644 index 00000000..fcbf3b3b --- /dev/null +++ b/IdentityServer/v8/DPoP/DPoP.AppHost/DPoP.AppHost.csproj @@ -0,0 +1,21 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + + + diff --git a/IdentityServer/v8/DPoP/DPoP.AppHost/Properties/launchSettings.json b/IdentityServer/v8/DPoP/DPoP.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..082bcac5 --- /dev/null +++ b/IdentityServer/v8/DPoP/DPoP.AppHost/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:17008;http://localhost:15008", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21008", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23008", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22008" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15008", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19008", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18008", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20008" + } + } + } +} diff --git a/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.Development.json b/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.Development.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.json b/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v8/DPoP/DPoP.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v8/DPoP/DPoP.sln b/IdentityServer/v8/DPoP/DPoP.sln index 8af1c263..66bfaa25 100644 --- a/IdentityServer/v8/DPoP/DPoP.sln +++ b/IdentityServer/v8/DPoP/DPoP.sln @@ -11,28 +11,78 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebClient", "WebClient\WebC EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServerHost", "..\IdentityServerHost\src\IdentityServerHost.csproj", "{60375429-8C38-4A49-BCBF-1AD486D33EDC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DPoP.AppHost", "DPoP.AppHost\DPoP.AppHost.csproj", "{D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x64.ActiveCfg = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x64.Build.0 = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x86.ActiveCfg = Debug|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Debug|x86.Build.0 = Debug|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|Any CPU.Build.0 = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x64.ActiveCfg = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x64.Build.0 = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x86.ActiveCfg = Release|Any CPU + {1EDEC089-0640-44D0-8566-FFAB1F078F8A}.Release|x86.Build.0 = Release|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x64.ActiveCfg = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x64.Build.0 = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Debug|x86.Build.0 = Debug|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|Any CPU.ActiveCfg = Release|Any CPU {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|Any CPU.Build.0 = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x64.ActiveCfg = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x64.Build.0 = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x86.ActiveCfg = Release|Any CPU + {DC45EDC7-CE9F-4928-A847-FA20A59E15A0}.Release|x86.Build.0 = Release|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x64.ActiveCfg = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x64.Build.0 = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x86.ActiveCfg = Debug|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Debug|x86.Build.0 = Debug|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|Any CPU.Build.0 = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x64.ActiveCfg = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x64.Build.0 = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x86.ActiveCfg = Release|Any CPU + {CB8E6070-4964-4A52-A58C-3E9F67A4EEC4}.Release|x86.Build.0 = Release|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x64.ActiveCfg = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x64.Build.0 = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x86.ActiveCfg = Debug|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Debug|x86.Build.0 = Debug|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|Any CPU.Build.0 = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x64.ActiveCfg = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x64.Build.0 = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x86.ActiveCfg = Release|Any CPU + {60375429-8C38-4A49-BCBF-1AD486D33EDC}.Release|x86.Build.0 = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|x64.Build.0 = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|x86.ActiveCfg = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Debug|x86.Build.0 = Debug|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|Any CPU.Build.0 = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|x64.ActiveCfg = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|x64.Build.0 = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|x86.ActiveCfg = Release|Any CPU + {D10B1BD1-8D21-4749-BD33-09FEF19EB3A2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/IdentityServer/v8/DPoP/WebClient/Program.cs b/IdentityServer/v8/DPoP/WebClient/Program.cs index cd0080f7..65423fb6 100644 --- a/IdentityServer/v8/DPoP/WebClient/Program.cs +++ b/IdentityServer/v8/DPoP/WebClient/Program.cs @@ -7,19 +7,12 @@ using Duende.AccessTokenManagement.OpenIdConnect; using Microsoft.AspNetCore.Authentication; using Microsoft.IdentityModel.Tokens; -using Serilog; Console.Title = "WebClient"; -Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}") - .CreateLogger(); - var builder = WebApplication.CreateBuilder(args); -builder.Services.AddSerilog(); +builder.AddServiceDefaults(); builder.Services.AddControllersWithViews(); // add cookie-based session management with OpenID Connect authentication @@ -94,6 +87,7 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); app.UseStaticFiles(); diff --git a/IdentityServer/v8/DPoP/WebClient/WebClient.csproj b/IdentityServer/v8/DPoP/WebClient/WebClient.csproj index cf9d37d9..076d07ff 100644 --- a/IdentityServer/v8/DPoP/WebClient/WebClient.csproj +++ b/IdentityServer/v8/DPoP/WebClient/WebClient.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v8/IdentityServerHost/src/HostingExtensions.cs b/IdentityServer/v8/IdentityServerHost/src/HostingExtensions.cs index bf32a6f1..e2e4bad2 100644 --- a/IdentityServer/v8/IdentityServerHost/src/HostingExtensions.cs +++ b/IdentityServer/v8/IdentityServerHost/src/HostingExtensions.cs @@ -6,22 +6,17 @@ using Duende.IdentityServer.ConformanceReport; using IdentityServerHost; using Microsoft.AspNetCore.DataProtection; -using Serilog; internal static class HostingExtensions { public static WebApplication ConfigureServices(this WebApplicationBuilder builder) { + builder.AddServiceDefaults(); builder.Services.AddRazorPages(); var idsvrBuilder = builder.Services .AddIdentityServer(options => { - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - // see https://docs.duendesoftware.com/identityserver/fundamentals/resources/api-scopes options.EmitStaticAudienceClaim = true; options.PushedAuthorization.AllowUnregisteredPushedRedirectUris = true; @@ -73,7 +68,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde public static WebApplication ConfigurePipeline(this WebApplication app) { - app.UseSerilogRequestLogging(); + app.MapDefaultEndpoints(); if (app.Environment.IsDevelopment()) { diff --git a/IdentityServer/v8/IdentityServerHost/src/IdentityServerHost.csproj b/IdentityServer/v8/IdentityServerHost/src/IdentityServerHost.csproj index 737ef9d6..707131fa 100755 --- a/IdentityServer/v8/IdentityServerHost/src/IdentityServerHost.csproj +++ b/IdentityServer/v8/IdentityServerHost/src/IdentityServerHost.csproj @@ -8,7 +8,10 @@ - + + + + diff --git a/IdentityServer/v8/IdentityServerHost/src/Program.cs b/IdentityServer/v8/IdentityServerHost/src/Program.cs index c25e5e99..f2828065 100755 --- a/IdentityServer/v8/IdentityServerHost/src/Program.cs +++ b/IdentityServer/v8/IdentityServerHost/src/Program.cs @@ -1,41 +1,10 @@ // Copyright (c) Duende Software. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -using Serilog; -using Serilog.Events; -using Serilog.Sinks.SystemConsole.Themes; +var builder = WebApplication.CreateBuilder(args); -Log.Logger = new LoggerConfiguration() - .WriteTo.Console() - .CreateBootstrapLogger(); +var app = builder + .ConfigureServices() + .ConfigurePipeline(); -Log.Information("Starting up"); - -try -{ - var builder = WebApplication.CreateBuilder(args); - - builder.Host.UseSerilog((ctx, lc) => lc - .MinimumLevel.Debug() - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) - .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information) - .MinimumLevel.Override("System", LogEventLevel.Warning) - .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information) - .Enrich.FromLogContext() - .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)); - - var app = builder - .ConfigureServices() - .ConfigurePipeline(); - - app.Run(); -} -catch (Exception ex) -{ - Log.Fatal(ex, "Unhandled exception"); -} -finally -{ - Log.Information("Shut down complete"); - Log.CloseAndFlush(); -} +app.Run(); diff --git a/samples.slnx b/samples.slnx index c39747e0..a2ac0267 100644 --- a/samples.slnx +++ b/samples.slnx @@ -259,6 +259,7 @@ + @@ -475,6 +476,7 @@ +