Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions IdentityServer/v7/Apis/SimpleApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
// 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;

Console.Title = "Simple API";
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("System", LogEventLevel.Information)
.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)
.CreateLogger();

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.Services.AddSerilog();

builder.Services.AddControllers();

// Attention: This API will accept any access token from the authority in this configuration
Expand Down
1 change: 0 additions & 1 deletion IdentityServer/v7/Apis/SimpleApi/SimpleApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

<ItemGroup>
Expand Down
48 changes: 14 additions & 34 deletions IdentityServer/v7/Configuration/IdentityServerHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,22 @@
using IdentityServer;
using Microsoft.Extensions.Hosting;

Console.Title = "IdentityServer Host";
var builder = WebApplication.CreateBuilder(args);

try
{
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.AddServiceDefaults();

var app = builder
.ConfigureServices()
.ConfigurePipeline();
var app = builder
.ConfigureServices()
.ConfigurePipeline();

// this seeding is only for the template to bootstrap the DB and users.
// in production you will likely want a different approach.
if (args.Contains("/seed"))
{
Console.WriteLine("Seeding database...");
SeedData.EnsureSeedData(app);
Console.WriteLine("Done seeding database. Exiting.");
return;
}

app.Run();
}
catch (Exception ex) when (
// https://github.com/dotnet/runtime/issues/60600
ex.GetType().Name is not "StopTheHostException"
// HostAbortedException was added in .NET 7, but since we target .NET 6 we
// need to do it this way until we target .NET 8
&& ex.GetType().Name is not "HostAbortedException"
)
// this seeding is only for the template to bootstrap the DB and users.
// in production you will likely want a different approach.
if (args.Contains("/seed"))
{
Console.WriteLine("Unhandled exception");
Console.WriteLine(ex);
}
finally
{
Console.WriteLine("Shut down complete");
Console.WriteLine("Seeding database...");
SeedData.EnsureSeedData(app);
Console.WriteLine("Done seeding database. Exiting.");
return;
}

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.Configuration" />
<PackageReference Include="Duende.IdentityServer.Configuration.EntityFramework" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
using Duende.IdentityServer.EntityFramework.Storage;
using Microsoft.EntityFrameworkCore;

Console.Title = "Configuration API";

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Services.AddIdentityServerConfiguration(opt => { })
.AddClientConfigurationStore();

Expand Down Expand Up @@ -40,6 +39,8 @@

var app = builder.Build();

app.MapDefaultEndpoints();

app.UseAuthentication();
app.UseAuthorization();
app.MapDynamicClientRegistration().RequireAuthorization("DCR");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var builder = DistributedApplication.CreateBuilder(args);

var idp = builder.AddProject<Projects.IdentityServer>("identityserverhost");

var configuration = builder.AddProject<Projects.Configuration>("configuration-api")
.WaitFor(idp);

builder.AddProject<Projects.SimpleApi>("simple-api")
.WaitFor(idp);

builder.AddProject<Projects.ConsoleDcrClient>("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();
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\IdentityServerHost\IdentityServer.csproj" />
<ProjectReference Include="..\Configuration\Configuration.csproj" />
<ProjectReference Include="..\ConsoleDcrClient\ConsoleDcrClient.csproj" />
<ProjectReference Include="..\..\..\Apis\SimpleApi\SimpleApi.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17149;http://localhost:15392",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21177",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23178",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22126"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15392",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19222",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18151",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20036"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,80 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer", "..\Identi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleApi", "..\..\Apis\SimpleApi\SimpleApi.csproj", "{1F141D4D-C27D-4A94-B518-80369AFE33E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PipelineRegistration.AppHost", "PipelineRegistration.AppHost\PipelineRegistration.AppHost.csproj", "{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}"
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
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|x64.ActiveCfg = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|x64.Build.0 = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|x86.ActiveCfg = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Debug|x86.Build.0 = Debug|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|Any CPU.Build.0 = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|x64.ActiveCfg = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|x64.Build.0 = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|x86.ActiveCfg = Release|Any CPU
{E0A37C31-D760-4CE0-925B-756BDDE6EFAA}.Release|x86.Build.0 = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|x64.ActiveCfg = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|x64.Build.0 = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|x86.ActiveCfg = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Debug|x86.Build.0 = Debug|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|Any CPU.Build.0 = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|x64.ActiveCfg = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|x64.Build.0 = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|x86.ActiveCfg = Release|Any CPU
{1F141D4D-C27D-4A94-B518-80369AFE33E2}.Release|x86.Build.0 = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|x64.ActiveCfg = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|x64.Build.0 = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|x86.ActiveCfg = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Debug|x86.Build.0 = Debug|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|Any CPU.Build.0 = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|x64.ActiveCfg = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|x64.Build.0 = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|x86.ActiveCfg = Release|Any CPU
{8F7BBD2B-6C13-409F-8442-C8DF4E942FB6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
16 changes: 0 additions & 16 deletions IdentityServer/v8/Apis/SimpleApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,26 +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;

Console.Title = "Simple API";
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("System", LogEventLevel.Information)
.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)
.CreateLogger();

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.Services.AddSerilog();

builder.Services.AddControllers();

// Attention: This API will accept any access token from the authority in this configuration
Expand Down
1 change: 0 additions & 1 deletion IdentityServer/v8/Apis/SimpleApi/SimpleApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading