diff --git a/IdentityServer/v7/Configuration/IdentityServerHost/HostingExtensions.cs b/IdentityServer/v7/Configuration/IdentityServerHost/HostingExtensions.cs
index 5031bdbc..ff98538e 100644
--- a/IdentityServer/v7/Configuration/IdentityServerHost/HostingExtensions.cs
+++ b/IdentityServer/v7/Configuration/IdentityServerHost/HostingExtensions.cs
@@ -8,7 +8,7 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
-using Serilog;
+using Microsoft.Extensions.Hosting;
namespace IdentityServer;
@@ -23,11 +23,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
var isBuilder = 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
options.EmitStaticAudienceClaim = true;
})
@@ -105,13 +100,13 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
public static WebApplication ConfigurePipeline(this WebApplication app)
{
- app.UseSerilogRequestLogging();
-
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
+ app.MapDefaultEndpoints();
+
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
diff --git a/IdentityServer/v7/Configuration/IdentityServerHost/IdentityServer.csproj b/IdentityServer/v7/Configuration/IdentityServerHost/IdentityServer.csproj
index a78af59a..a26edd3d 100644
--- a/IdentityServer/v7/Configuration/IdentityServerHost/IdentityServer.csproj
+++ b/IdentityServer/v7/Configuration/IdentityServerHost/IdentityServer.csproj
@@ -8,7 +8,6 @@
-
@@ -20,5 +19,7 @@
-
+
+
+
diff --git a/IdentityServer/v7/Configuration/IdentityServerHost/Program.cs b/IdentityServer/v7/Configuration/IdentityServerHost/Program.cs
index 43e949dc..36263979 100644
--- a/IdentityServer/v7/Configuration/IdentityServerHost/Program.cs
+++ b/IdentityServer/v7/Configuration/IdentityServerHost/Program.cs
@@ -3,24 +3,15 @@
using System.Globalization;
using IdentityServer;
-using Serilog;
+using Microsoft.Extensions.Hosting;
Console.Title = "IdentityServer Host";
-Log.Logger = new LoggerConfiguration()
- .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
- .CreateBootstrapLogger();
-
-Log.Information("Starting up");
-
try
{
var builder = WebApplication.CreateBuilder(args);
- builder.Host.UseSerilog((ctx, lc) => lc
- .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", formatProvider: CultureInfo.InvariantCulture)
- .Enrich.FromLogContext()
- .ReadFrom.Configuration(ctx.Configuration));
+ builder.AddServiceDefaults();
var app = builder
.ConfigureServices()
@@ -30,9 +21,9 @@
// in production you will likely want a different approach.
if (args.Contains("/seed"))
{
- Log.Information("Seeding database...");
+ Console.WriteLine("Seeding database...");
SeedData.EnsureSeedData(app);
- Log.Information("Done seeding database. Exiting.");
+ Console.WriteLine("Done seeding database. Exiting.");
return;
}
@@ -46,10 +37,10 @@
&& ex.GetType().Name is not "HostAbortedException"
)
{
- Log.Fatal(ex, "Unhandled exception");
+ Console.WriteLine("Unhandled exception");
+ Console.WriteLine(ex);
}
finally
{
- Log.Information("Shut down complete");
- Log.CloseAndFlush();
+ Console.WriteLine("Shut down complete");
}
diff --git a/IdentityServer/v7/Configuration/IdentityServerHost/SeedData.cs b/IdentityServer/v7/Configuration/IdentityServerHost/SeedData.cs
index 9fc23c9f..1e8349b7 100644
--- a/IdentityServer/v7/Configuration/IdentityServerHost/SeedData.cs
+++ b/IdentityServer/v7/Configuration/IdentityServerHost/SeedData.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
using Microsoft.EntityFrameworkCore;
-using Serilog;
namespace IdentityServer;
@@ -27,7 +26,7 @@ private static void EnsureSeedData(ConfigurationDbContext context)
{
if (!context.Clients.Any())
{
- Log.Debug("Clients being populated");
+ Console.WriteLine("Clients being populated");
foreach (var client in Config.Clients.ToList())
{
context.Clients.Add(client.ToEntity());
@@ -36,12 +35,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("Clients already populated");
+ Console.WriteLine("Clients already populated");
}
if (!context.IdentityResources.Any())
{
- Log.Debug("IdentityResources being populated");
+ Console.WriteLine("IdentityResources being populated");
foreach (var resource in Config.IdentityResources.ToList())
{
context.IdentityResources.Add(resource.ToEntity());
@@ -50,12 +49,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("IdentityResources already populated");
+ Console.WriteLine("IdentityResources already populated");
}
if (!context.ApiScopes.Any())
{
- Log.Debug("ApiScopes being populated");
+ Console.WriteLine("ApiScopes being populated");
foreach (var apiScope in Config.ApiScopes.ToList())
{
context.ApiScopes.Add(apiScope.ToEntity());
@@ -64,12 +63,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("ApiScopes already populated");
+ Console.WriteLine("ApiScopes already populated");
}
if (!context.ApiResources.Any())
{
- Log.Debug("ApiResources being populated");
+ Console.WriteLine("ApiResources being populated");
foreach (var resource in Config.ApiResources.ToList())
{
context.ApiResources.Add(resource.ToEntity());
@@ -78,12 +77,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("ApiResources already populated");
+ Console.WriteLine("ApiResources already populated");
}
if (!context.IdentityProviders.Any())
{
- Log.Debug("OIDC IdentityProviders being populated");
+ Console.WriteLine("OIDC IdentityProviders being populated");
context.IdentityProviders.Add(new OidcProvider
{
Scheme = "demoidsrv",
@@ -95,7 +94,7 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("OIDC IdentityProviders already populated");
+ Console.WriteLine("OIDC IdentityProviders already populated");
}
}
}
diff --git a/IdentityServer/v7/Configuration/Permissions/Configuration/Configuration.csproj b/IdentityServer/v7/Configuration/Permissions/Configuration/Configuration.csproj
index 5db2b431..fc905bd0 100644
--- a/IdentityServer/v7/Configuration/Permissions/Configuration/Configuration.csproj
+++ b/IdentityServer/v7/Configuration/Permissions/Configuration/Configuration.csproj
@@ -12,5 +12,7 @@
-
+
+
+
diff --git a/IdentityServer/v7/Configuration/Permissions/Configuration/Program.cs b/IdentityServer/v7/Configuration/Permissions/Configuration/Program.cs
index 88c1cc33..ff7921b9 100644
--- a/IdentityServer/v7/Configuration/Permissions/Configuration/Program.cs
+++ b/IdentityServer/v7/Configuration/Permissions/Configuration/Program.cs
@@ -8,10 +8,12 @@
using Duende.IdentityServer.EntityFramework.DbContexts;
using Duende.IdentityServer.EntityFramework.Storage;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Hosting;
Console.Title = "Configuration API";
var builder = WebApplication.CreateBuilder(args);
+builder.AddServiceDefaults();
builder.Services.AddIdentityServerConfiguration(opt => { })
.AddClientConfigurationStore();
@@ -44,6 +46,8 @@
var app = builder.Build();
+app.MapDefaultEndpoints();
+
app.UseAuthentication();
app.UseAuthorization();
app.MapDynamicClientRegistration().RequireAuthorization("DCR");
diff --git a/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/AppHost.cs b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/AppHost.cs
new file mode 100644
index 00000000..a1c73dcb
--- /dev/null
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/AppHost.cs
@@ -0,0 +1,54 @@
+var builder = DistributedApplication.CreateBuilder(args);
+
+var idp = builder.AddProject("identityserverhost");
+
+var configuration = builder.AddProject("configuration-api")
+ .WaitFor(idp);
+
+builder.AddProject("simple-api")
+ .WaitFor(idp);
+
+builder.AddProject("console-dcr-client")
+ .WaitFor(idp)
+ .WaitFor(configuration);
+
+idp.WithCommand(
+ name: "seed",
+ displayName: "Seed Database",
+ executeCommand: async (context) =>
+ {
+ var projectMetadata = idp.Resource.GetProjectMetadata();
+ var projectPath = projectMetadata.ProjectPath;
+ var process = new System.Diagnostics.Process
+ {
+ StartInfo = new System.Diagnostics.ProcessStartInfo
+ {
+ FileName = "dotnet",
+ Arguments = $"run --project \"{projectPath}\" --no-build -- /seed",
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ CreateNoWindow = true
+ }
+ };
+
+ process.Start();
+ await process.WaitForExitAsync(context.CancellationToken);
+
+ if (process.ExitCode == 0)
+ {
+ return CommandResults.Success();
+ }
+ else
+ {
+ var error = await process.StandardError.ReadToEndAsync();
+ return CommandResults.Failure(error);
+ }
+ },
+ commandOptions: new CommandOptions
+ {
+ IconName = "DatabaseArrowUp",
+ IsHighlighted = true
+ });
+
+builder.Build().Run();
diff --git a/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj
new file mode 100644
index 00000000..34970118
--- /dev/null
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj
@@ -0,0 +1,21 @@
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/Properties/launchSettings.json b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/Properties/launchSettings.json
new file mode 100644
index 00000000..415172a6
--- /dev/null
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.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/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/appsettings.json b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/appsettings.json
new file mode 100644
index 00000000..31c092aa
--- /dev/null
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.AppHost/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning",
+ "Aspire.Hosting.Dcp": "Warning"
+ }
+ }
+}
diff --git a/IdentityServer/v7/Configuration/Permissions/Permissions.sln b/IdentityServer/v7/Configuration/Permissions/Permissions.sln
index 94968a8d..268012c9 100644
--- a/IdentityServer/v7/Configuration/Permissions/Permissions.sln
+++ b/IdentityServer/v7/Configuration/Permissions/Permissions.sln
@@ -11,30 +11,80 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer", "..\Identi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "..\..\Apis\SimpleApi\SimpleApi.csproj", "{52E6BB46-1B26-431D-B13E-D58734BFF1B2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Permissions.AppHost", "Permissions.AppHost\Permissions.AppHost.csproj", "{134DF05E-813E-472D-B8AC-5246E21394C6}"
+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
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x64.Build.0 = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x86.Build.0 = Debug|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x64.ActiveCfg = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x64.Build.0 = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x86.ActiveCfg = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x86.Build.0 = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x64.Build.0 = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x86.Build.0 = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x64.ActiveCfg = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x64.Build.0 = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x86.ActiveCfg = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x86.Build.0 = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x64.Build.0 = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x86.Build.0 = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x64.ActiveCfg = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x64.Build.0 = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x86.ActiveCfg = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x86.Build.0 = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x64.Build.0 = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x86.Build.0 = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x64.ActiveCfg = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x64.Build.0 = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x86.ActiveCfg = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x86.Build.0 = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|x64.Build.0 = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Debug|x86.Build.0 = Debug|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|x64.ActiveCfg = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|x64.Build.0 = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|x86.ActiveCfg = Release|Any CPU
+ {134DF05E-813E-472D-B8AC-5246E21394C6}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
diff --git a/IdentityServer/v8/Configuration/IdentityServerHost/HostingExtensions.cs b/IdentityServer/v8/Configuration/IdentityServerHost/HostingExtensions.cs
index 5031bdbc..ff98538e 100644
--- a/IdentityServer/v8/Configuration/IdentityServerHost/HostingExtensions.cs
+++ b/IdentityServer/v8/Configuration/IdentityServerHost/HostingExtensions.cs
@@ -8,7 +8,7 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
-using Serilog;
+using Microsoft.Extensions.Hosting;
namespace IdentityServer;
@@ -23,11 +23,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
var isBuilder = 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
options.EmitStaticAudienceClaim = true;
})
@@ -105,13 +100,13 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
public static WebApplication ConfigurePipeline(this WebApplication app)
{
- app.UseSerilogRequestLogging();
-
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
+ app.MapDefaultEndpoints();
+
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
diff --git a/IdentityServer/v8/Configuration/IdentityServerHost/IdentityServer.csproj b/IdentityServer/v8/Configuration/IdentityServerHost/IdentityServer.csproj
index 755aece5..66355d57 100644
--- a/IdentityServer/v8/Configuration/IdentityServerHost/IdentityServer.csproj
+++ b/IdentityServer/v8/Configuration/IdentityServerHost/IdentityServer.csproj
@@ -8,7 +8,6 @@
-
@@ -20,5 +19,7 @@
-
+
+
+
diff --git a/IdentityServer/v8/Configuration/IdentityServerHost/Program.cs b/IdentityServer/v8/Configuration/IdentityServerHost/Program.cs
index 43e949dc..36263979 100644
--- a/IdentityServer/v8/Configuration/IdentityServerHost/Program.cs
+++ b/IdentityServer/v8/Configuration/IdentityServerHost/Program.cs
@@ -3,24 +3,15 @@
using System.Globalization;
using IdentityServer;
-using Serilog;
+using Microsoft.Extensions.Hosting;
Console.Title = "IdentityServer Host";
-Log.Logger = new LoggerConfiguration()
- .WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
- .CreateBootstrapLogger();
-
-Log.Information("Starting up");
-
try
{
var builder = WebApplication.CreateBuilder(args);
- builder.Host.UseSerilog((ctx, lc) => lc
- .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", formatProvider: CultureInfo.InvariantCulture)
- .Enrich.FromLogContext()
- .ReadFrom.Configuration(ctx.Configuration));
+ builder.AddServiceDefaults();
var app = builder
.ConfigureServices()
@@ -30,9 +21,9 @@
// in production you will likely want a different approach.
if (args.Contains("/seed"))
{
- Log.Information("Seeding database...");
+ Console.WriteLine("Seeding database...");
SeedData.EnsureSeedData(app);
- Log.Information("Done seeding database. Exiting.");
+ Console.WriteLine("Done seeding database. Exiting.");
return;
}
@@ -46,10 +37,10 @@
&& ex.GetType().Name is not "HostAbortedException"
)
{
- Log.Fatal(ex, "Unhandled exception");
+ Console.WriteLine("Unhandled exception");
+ Console.WriteLine(ex);
}
finally
{
- Log.Information("Shut down complete");
- Log.CloseAndFlush();
+ Console.WriteLine("Shut down complete");
}
diff --git a/IdentityServer/v8/Configuration/IdentityServerHost/SeedData.cs b/IdentityServer/v8/Configuration/IdentityServerHost/SeedData.cs
index 9fc23c9f..1e8349b7 100644
--- a/IdentityServer/v8/Configuration/IdentityServerHost/SeedData.cs
+++ b/IdentityServer/v8/Configuration/IdentityServerHost/SeedData.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
using Microsoft.EntityFrameworkCore;
-using Serilog;
namespace IdentityServer;
@@ -27,7 +26,7 @@ private static void EnsureSeedData(ConfigurationDbContext context)
{
if (!context.Clients.Any())
{
- Log.Debug("Clients being populated");
+ Console.WriteLine("Clients being populated");
foreach (var client in Config.Clients.ToList())
{
context.Clients.Add(client.ToEntity());
@@ -36,12 +35,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("Clients already populated");
+ Console.WriteLine("Clients already populated");
}
if (!context.IdentityResources.Any())
{
- Log.Debug("IdentityResources being populated");
+ Console.WriteLine("IdentityResources being populated");
foreach (var resource in Config.IdentityResources.ToList())
{
context.IdentityResources.Add(resource.ToEntity());
@@ -50,12 +49,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("IdentityResources already populated");
+ Console.WriteLine("IdentityResources already populated");
}
if (!context.ApiScopes.Any())
{
- Log.Debug("ApiScopes being populated");
+ Console.WriteLine("ApiScopes being populated");
foreach (var apiScope in Config.ApiScopes.ToList())
{
context.ApiScopes.Add(apiScope.ToEntity());
@@ -64,12 +63,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("ApiScopes already populated");
+ Console.WriteLine("ApiScopes already populated");
}
if (!context.ApiResources.Any())
{
- Log.Debug("ApiResources being populated");
+ Console.WriteLine("ApiResources being populated");
foreach (var resource in Config.ApiResources.ToList())
{
context.ApiResources.Add(resource.ToEntity());
@@ -78,12 +77,12 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("ApiResources already populated");
+ Console.WriteLine("ApiResources already populated");
}
if (!context.IdentityProviders.Any())
{
- Log.Debug("OIDC IdentityProviders being populated");
+ Console.WriteLine("OIDC IdentityProviders being populated");
context.IdentityProviders.Add(new OidcProvider
{
Scheme = "demoidsrv",
@@ -95,7 +94,7 @@ private static void EnsureSeedData(ConfigurationDbContext context)
}
else
{
- Log.Debug("OIDC IdentityProviders already populated");
+ Console.WriteLine("OIDC IdentityProviders already populated");
}
}
}
diff --git a/IdentityServer/v8/Configuration/Permissions/Configuration/Configuration.csproj b/IdentityServer/v8/Configuration/Permissions/Configuration/Configuration.csproj
index 5db2b431..fc905bd0 100644
--- a/IdentityServer/v8/Configuration/Permissions/Configuration/Configuration.csproj
+++ b/IdentityServer/v8/Configuration/Permissions/Configuration/Configuration.csproj
@@ -12,5 +12,7 @@
-
+
+
+
diff --git a/IdentityServer/v8/Configuration/Permissions/Configuration/Program.cs b/IdentityServer/v8/Configuration/Permissions/Configuration/Program.cs
index 88c1cc33..ff7921b9 100644
--- a/IdentityServer/v8/Configuration/Permissions/Configuration/Program.cs
+++ b/IdentityServer/v8/Configuration/Permissions/Configuration/Program.cs
@@ -8,10 +8,12 @@
using Duende.IdentityServer.EntityFramework.DbContexts;
using Duende.IdentityServer.EntityFramework.Storage;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Hosting;
Console.Title = "Configuration API";
var builder = WebApplication.CreateBuilder(args);
+builder.AddServiceDefaults();
builder.Services.AddIdentityServerConfiguration(opt => { })
.AddClientConfigurationStore();
@@ -44,6 +46,8 @@
var app = builder.Build();
+app.MapDefaultEndpoints();
+
app.UseAuthentication();
app.UseAuthorization();
app.MapDynamicClientRegistration().RequireAuthorization("DCR");
diff --git a/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/AppHost.cs b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/AppHost.cs
new file mode 100644
index 00000000..a1c73dcb
--- /dev/null
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/AppHost.cs
@@ -0,0 +1,54 @@
+var builder = DistributedApplication.CreateBuilder(args);
+
+var idp = builder.AddProject("identityserverhost");
+
+var configuration = builder.AddProject("configuration-api")
+ .WaitFor(idp);
+
+builder.AddProject("simple-api")
+ .WaitFor(idp);
+
+builder.AddProject("console-dcr-client")
+ .WaitFor(idp)
+ .WaitFor(configuration);
+
+idp.WithCommand(
+ name: "seed",
+ displayName: "Seed Database",
+ executeCommand: async (context) =>
+ {
+ var projectMetadata = idp.Resource.GetProjectMetadata();
+ var projectPath = projectMetadata.ProjectPath;
+ var process = new System.Diagnostics.Process
+ {
+ StartInfo = new System.Diagnostics.ProcessStartInfo
+ {
+ FileName = "dotnet",
+ Arguments = $"run --project \"{projectPath}\" --no-build -- /seed",
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ CreateNoWindow = true
+ }
+ };
+
+ process.Start();
+ await process.WaitForExitAsync(context.CancellationToken);
+
+ if (process.ExitCode == 0)
+ {
+ return CommandResults.Success();
+ }
+ else
+ {
+ var error = await process.StandardError.ReadToEndAsync();
+ return CommandResults.Failure(error);
+ }
+ },
+ commandOptions: new CommandOptions
+ {
+ IconName = "DatabaseArrowUp",
+ IsHighlighted = true
+ });
+
+builder.Build().Run();
diff --git a/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj
new file mode 100644
index 00000000..34970118
--- /dev/null
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/Permissions.AppHost.csproj
@@ -0,0 +1,21 @@
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/Properties/launchSettings.json b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/Properties/launchSettings.json
new file mode 100644
index 00000000..667942c6
--- /dev/null
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.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/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json
new file mode 100644
index 00000000..0c208ae9
--- /dev/null
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/appsettings.json b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/appsettings.json
new file mode 100644
index 00000000..31c092aa
--- /dev/null
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.AppHost/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning",
+ "Aspire.Hosting.Dcp": "Warning"
+ }
+ }
+}
diff --git a/IdentityServer/v8/Configuration/Permissions/Permissions.sln b/IdentityServer/v8/Configuration/Permissions/Permissions.sln
index 94968a8d..08ecc45c 100644
--- a/IdentityServer/v8/Configuration/Permissions/Permissions.sln
+++ b/IdentityServer/v8/Configuration/Permissions/Permissions.sln
@@ -11,30 +11,80 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer", "..\Identi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "..\..\Apis\SimpleApi\SimpleApi.csproj", "{52E6BB46-1B26-431D-B13E-D58734BFF1B2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Permissions.AppHost", "Permissions.AppHost\Permissions.AppHost.csproj", "{D257943F-BD65-4E2F-8ECE-266A76B56A62}"
+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
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x64.Build.0 = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Debug|x86.Build.0 = Debug|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x64.ActiveCfg = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x64.Build.0 = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x86.ActiveCfg = Release|Any CPU
+ {CD4E158A-9173-49A5-BF10-F5CAE6E5D3B1}.Release|x86.Build.0 = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x64.Build.0 = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Debug|x86.Build.0 = Debug|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D134466E-58AE-4787-984B-FB6F95EEA969}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x64.ActiveCfg = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x64.Build.0 = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x86.ActiveCfg = Release|Any CPU
+ {D134466E-58AE-4787-984B-FB6F95EEA969}.Release|x86.Build.0 = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x64.Build.0 = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Debug|x86.Build.0 = Debug|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x64.ActiveCfg = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x64.Build.0 = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x86.ActiveCfg = Release|Any CPU
+ {075FD8FE-6A12-4121-9163-F2A48001F37B}.Release|x86.Build.0 = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x64.Build.0 = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Debug|x86.Build.0 = Debug|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x64.ActiveCfg = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x64.Build.0 = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x86.ActiveCfg = Release|Any CPU
+ {52E6BB46-1B26-431D-B13E-D58734BFF1B2}.Release|x86.Build.0 = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|x64.Build.0 = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Debug|x86.Build.0 = Debug|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|x64.ActiveCfg = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|x64.Build.0 = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|x86.ActiveCfg = Release|Any CPU
+ {D257943F-BD65-4E2F-8ECE-266A76B56A62}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
diff --git a/samples.slnx b/samples.slnx
index a2ac0267..79f9f43b 100644
--- a/samples.slnx
+++ b/samples.slnx
@@ -231,6 +231,7 @@
+
@@ -448,6 +449,7 @@
+