diff --git a/IdentityServer/v7/McpDemo/McpDemo.AppHost/AppHost.cs b/IdentityServer/v7/McpDemo/McpDemo.AppHost/AppHost.cs new file mode 100644 index 00000000..d765f603 --- /dev/null +++ b/IdentityServer/v7/McpDemo/McpDemo.AppHost/AppHost.cs @@ -0,0 +1,12 @@ +var builder = DistributedApplication.CreateBuilder(args); + +var idp = builder.AddProject("mcpdemo-identityserver"); + +var mcpServer = builder.AddProject("mcpdemo-mcpserver") + .WaitFor(idp); + +builder.AddProject("mcpdemo-client") + .WaitFor(idp) + .WaitFor(mcpServer); + +builder.Build().Run(); diff --git a/IdentityServer/v7/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj b/IdentityServer/v7/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj new file mode 100644 index 00000000..f1e88f47 --- /dev/null +++ b/IdentityServer/v7/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj @@ -0,0 +1,20 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + + diff --git a/IdentityServer/v7/McpDemo/McpDemo.AppHost/Properties/launchSettings.json b/IdentityServer/v7/McpDemo/McpDemo.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..415172a6 --- /dev/null +++ b/IdentityServer/v7/McpDemo/McpDemo.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:17049;http://localhost:15292", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21176", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23177", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22125" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15292", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19221", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18150", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20035" + } + } + } +} diff --git a/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.Development.json b/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.json b/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs index a7893cfe..093df1ee 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs +++ b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs @@ -6,48 +6,11 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.IdentityModel.Tokens; -using Serilog; -using Serilog.Filters; namespace McpDemo.IdentityServer; internal static class HostingExtensions { - public static WebApplicationBuilder ConfigureLogging(this WebApplicationBuilder builder) - { - // Write most logs to the console but diagnostic data to a file. - // See https://docs.duendesoftware.com/identityserver/diagnostics/data - builder.Host.UseSerilog((ctx, lc) => - { - lc.WriteTo.Logger(consoleLogger => - { - consoleLogger.WriteTo.Console( - outputTemplate: - "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", - formatProvider: CultureInfo.InvariantCulture); - if (builder.Environment.IsDevelopment()) - { - consoleLogger.Filter.ByExcluding(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary")); - } - }); - if (builder.Environment.IsDevelopment()) - { - lc.WriteTo.Logger(fileLogger => - { - fileLogger - .WriteTo.File("./diagnostics/diagnostic.log", rollingInterval: RollingInterval.Day, - fileSizeLimitBytes: 1024 * 1024 * 10, // 10 MB - rollOnFileSizeLimit: true, - outputTemplate: - "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", - formatProvider: CultureInfo.InvariantCulture) - .Filter - .ByIncludingOnly(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary")); - }).Enrich.FromLogContext().ReadFrom.Configuration(ctx.Configuration); - } - }); - return builder; - } public static WebApplication ConfigureServices(this WebApplicationBuilder builder) { @@ -57,17 +20,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde { // this will add the default dynamic client registration endpoint to the discovery/metadatada documents options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.Inferred; - - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - - // Use a large chunk size for diagnostic logs in development where it will be redirected to a local file - if (builder.Environment.IsDevelopment()) - { - options.Diagnostics.ChunkSize = 1024 * 1024 * 10; // 10 MB - } }) .AddTestUsers(TestUsers.Users) .AddLicenseSummary(); @@ -113,7 +65,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/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj index ed4523c7..13c8d9d0 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj +++ b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/Program.cs b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/Program.cs index 8fb7544e..d957c912 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/Program.cs +++ b/IdentityServer/v7/McpDemo/McpDemo.IdentityServer/Program.cs @@ -2,20 +2,14 @@ using System.Text; using Duende.IdentityServer.Licensing; using McpDemo.IdentityServer; -using Serilog; - -Log.Logger = new LoggerConfiguration() - .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture) - .CreateBootstrapLogger(); - -Log.Information("Starting up"); try { var builder = WebApplication.CreateBuilder(args); + builder.AddServiceDefaults(); + var app = builder - .ConfigureLogging() .ConfigureServices() .ConfigurePipeline(); @@ -32,12 +26,7 @@ } catch (Exception ex) when (ex is not HostAbortedException) { - Log.Fatal(ex, "Unhandled exception"); -} -finally -{ - Log.Information("Shut down complete"); - Log.CloseAndFlush(); + throw; } static string Summary(LicenseUsageSummary usage) diff --git a/IdentityServer/v7/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj b/IdentityServer/v7/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj index 5e9abafb..6a1aea74 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj +++ b/IdentityServer/v7/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj @@ -11,4 +11,7 @@ + + + diff --git a/IdentityServer/v7/McpDemo/McpDemo.McpServer/Program.cs b/IdentityServer/v7/McpDemo/McpDemo.McpServer/Program.cs index 8d40db63..55e04538 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.McpServer/Program.cs +++ b/IdentityServer/v7/McpDemo/McpDemo.McpServer/Program.cs @@ -6,6 +6,8 @@ var builder = WebApplication.CreateBuilder(args); +builder.AddServiceDefaults(); + var serverUrl = "https://localhost:7141"; var inMemoryOAuthServerUrl = "https://localhost:5001/"; @@ -53,6 +55,8 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); + app.UseAuthentication(); app.UseAuthorization(); diff --git a/IdentityServer/v7/McpDemo/McpDemo.sln b/IdentityServer/v7/McpDemo/McpDemo.sln index 27f673a2..956b3951 100644 --- a/IdentityServer/v7/McpDemo/McpDemo.sln +++ b/IdentityServer/v7/McpDemo/McpDemo.sln @@ -6,23 +6,68 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.IdentityServer", "M EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.Client", "McpDemo.Client\McpDemo.Client.csproj", "{8D81440F-4979-4964-B851-2AE6BF348D01}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.AppHost", "McpDemo.AppHost\McpDemo.AppHost.csproj", "{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}" +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 {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.ActiveCfg = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.Build.0 = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.ActiveCfg = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.Build.0 = Debug|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.Build.0 = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.ActiveCfg = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.Build.0 = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.ActiveCfg = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.Build.0 = Release|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.ActiveCfg = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.Build.0 = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.ActiveCfg = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.Build.0 = Debug|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.Build.0 = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.ActiveCfg = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.Build.0 = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.ActiveCfg = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.Build.0 = Release|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.ActiveCfg = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.Build.0 = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.ActiveCfg = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.Build.0 = Debug|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.Build.0 = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.ActiveCfg = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.Build.0 = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.ActiveCfg = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.Build.0 = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x64.ActiveCfg = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x64.Build.0 = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x86.ActiveCfg = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x86.Build.0 = Debug|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|Any CPU.Build.0 = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x64.ActiveCfg = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x64.Build.0 = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x86.ActiveCfg = Release|Any CPU + {0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/IdentityServer/v8/McpDemo/McpDemo.AppHost/AppHost.cs b/IdentityServer/v8/McpDemo/McpDemo.AppHost/AppHost.cs new file mode 100644 index 00000000..d765f603 --- /dev/null +++ b/IdentityServer/v8/McpDemo/McpDemo.AppHost/AppHost.cs @@ -0,0 +1,12 @@ +var builder = DistributedApplication.CreateBuilder(args); + +var idp = builder.AddProject("mcpdemo-identityserver"); + +var mcpServer = builder.AddProject("mcpdemo-mcpserver") + .WaitFor(idp); + +builder.AddProject("mcpdemo-client") + .WaitFor(idp) + .WaitFor(mcpServer); + +builder.Build().Run(); diff --git a/IdentityServer/v8/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj b/IdentityServer/v8/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj new file mode 100644 index 00000000..f1e88f47 --- /dev/null +++ b/IdentityServer/v8/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj @@ -0,0 +1,20 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + + diff --git a/IdentityServer/v8/McpDemo/McpDemo.AppHost/Properties/launchSettings.json b/IdentityServer/v8/McpDemo/McpDemo.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..667942c6 --- /dev/null +++ b/IdentityServer/v8/McpDemo/McpDemo.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:17048;http://localhost:15291", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21175", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23176", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22124" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15291", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19220", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18149", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20034" + } + } + } +} diff --git a/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.Development.json b/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.json b/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs index a7893cfe..093df1ee 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs +++ b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/HostingExtensions.cs @@ -6,48 +6,11 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.IdentityModel.Tokens; -using Serilog; -using Serilog.Filters; namespace McpDemo.IdentityServer; internal static class HostingExtensions { - public static WebApplicationBuilder ConfigureLogging(this WebApplicationBuilder builder) - { - // Write most logs to the console but diagnostic data to a file. - // See https://docs.duendesoftware.com/identityserver/diagnostics/data - builder.Host.UseSerilog((ctx, lc) => - { - lc.WriteTo.Logger(consoleLogger => - { - consoleLogger.WriteTo.Console( - outputTemplate: - "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", - formatProvider: CultureInfo.InvariantCulture); - if (builder.Environment.IsDevelopment()) - { - consoleLogger.Filter.ByExcluding(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary")); - } - }); - if (builder.Environment.IsDevelopment()) - { - lc.WriteTo.Logger(fileLogger => - { - fileLogger - .WriteTo.File("./diagnostics/diagnostic.log", rollingInterval: RollingInterval.Day, - fileSizeLimitBytes: 1024 * 1024 * 10, // 10 MB - rollOnFileSizeLimit: true, - outputTemplate: - "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", - formatProvider: CultureInfo.InvariantCulture) - .Filter - .ByIncludingOnly(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary")); - }).Enrich.FromLogContext().ReadFrom.Configuration(ctx.Configuration); - } - }); - return builder; - } public static WebApplication ConfigureServices(this WebApplicationBuilder builder) { @@ -57,17 +20,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde { // this will add the default dynamic client registration endpoint to the discovery/metadatada documents options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.Inferred; - - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - - // Use a large chunk size for diagnostic logs in development where it will be redirected to a local file - if (builder.Environment.IsDevelopment()) - { - options.Diagnostics.ChunkSize = 1024 * 1024 * 10; // 10 MB - } }) .AddTestUsers(TestUsers.Users) .AddLicenseSummary(); @@ -113,7 +65,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/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj index ed4523c7..13c8d9d0 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj +++ b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/McpDemo.IdentityServer.csproj @@ -9,7 +9,10 @@ - + + + + diff --git a/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/Program.cs b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/Program.cs index 8fb7544e..d957c912 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/Program.cs +++ b/IdentityServer/v8/McpDemo/McpDemo.IdentityServer/Program.cs @@ -2,20 +2,14 @@ using System.Text; using Duende.IdentityServer.Licensing; using McpDemo.IdentityServer; -using Serilog; - -Log.Logger = new LoggerConfiguration() - .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture) - .CreateBootstrapLogger(); - -Log.Information("Starting up"); try { var builder = WebApplication.CreateBuilder(args); + builder.AddServiceDefaults(); + var app = builder - .ConfigureLogging() .ConfigureServices() .ConfigurePipeline(); @@ -32,12 +26,7 @@ } catch (Exception ex) when (ex is not HostAbortedException) { - Log.Fatal(ex, "Unhandled exception"); -} -finally -{ - Log.Information("Shut down complete"); - Log.CloseAndFlush(); + throw; } static string Summary(LicenseUsageSummary usage) diff --git a/IdentityServer/v8/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj b/IdentityServer/v8/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj index 5e9abafb..6a1aea74 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj +++ b/IdentityServer/v8/McpDemo/McpDemo.McpServer/McpDemo.McpServer.csproj @@ -11,4 +11,7 @@ + + + diff --git a/IdentityServer/v8/McpDemo/McpDemo.McpServer/Program.cs b/IdentityServer/v8/McpDemo/McpDemo.McpServer/Program.cs index 49f96685..1e5db1be 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.McpServer/Program.cs +++ b/IdentityServer/v8/McpDemo/McpDemo.McpServer/Program.cs @@ -6,6 +6,8 @@ var builder = WebApplication.CreateBuilder(args); +builder.AddServiceDefaults(); + var serverUrl = "https://localhost:7141"; var inMemoryOAuthServerUrl = "https://localhost:5001/"; @@ -53,6 +55,8 @@ var app = builder.Build(); +app.MapDefaultEndpoints(); + app.UseAuthentication(); app.UseAuthorization(); diff --git a/IdentityServer/v8/McpDemo/McpDemo.sln b/IdentityServer/v8/McpDemo/McpDemo.sln index 27f673a2..a05e2f33 100644 --- a/IdentityServer/v8/McpDemo/McpDemo.sln +++ b/IdentityServer/v8/McpDemo/McpDemo.sln @@ -6,23 +6,68 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.IdentityServer", "M EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.Client", "McpDemo.Client\McpDemo.Client.csproj", "{8D81440F-4979-4964-B851-2AE6BF348D01}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.AppHost", "McpDemo.AppHost\McpDemo.AppHost.csproj", "{394E83BB-3BA9-4DCA-A61A-99990D168A56}" +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 {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.ActiveCfg = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.Build.0 = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.ActiveCfg = Debug|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.Build.0 = Debug|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.ActiveCfg = Release|Any CPU {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.Build.0 = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.ActiveCfg = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.Build.0 = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.ActiveCfg = Release|Any CPU + {C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.Build.0 = Release|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.ActiveCfg = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.Build.0 = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.ActiveCfg = Debug|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.Build.0 = Debug|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.Build.0 = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.ActiveCfg = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.Build.0 = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.ActiveCfg = Release|Any CPU + {DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.Build.0 = Release|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.ActiveCfg = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.Build.0 = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.ActiveCfg = Debug|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.Build.0 = Debug|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.Build.0 = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.ActiveCfg = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.Build.0 = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.ActiveCfg = Release|Any CPU + {8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.Build.0 = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|Any CPU.Build.0 = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|x64.ActiveCfg = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|x64.Build.0 = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|x86.ActiveCfg = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Debug|x86.Build.0 = Debug|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|Any CPU.ActiveCfg = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|Any CPU.Build.0 = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|x64.ActiveCfg = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|x64.Build.0 = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|x86.ActiveCfg = Release|Any CPU + {394E83BB-3BA9-4DCA-A61A-99990D168A56}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/samples.slnx b/samples.slnx index 8bbe1f90..c39747e0 100644 --- a/samples.slnx +++ b/samples.slnx @@ -264,6 +264,7 @@ + @@ -479,6 +480,7 @@ +