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
5 changes: 4 additions & 1 deletion IdentityServer/v7/DPoP/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<ItemGroup>
<PackageReference Include="Duende.IdentityModel" />
<PackageReference Include="Duende.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

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

</Project>
11 changes: 2 additions & 9 deletions IdentityServer/v7/DPoP/Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -54,6 +46,7 @@

var app = builder.Build();

app.MapDefaultEndpoints();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
8 changes: 0 additions & 8 deletions IdentityServer/v7/DPoP/ClientCredentials/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) =>
{
Expand Down
15 changes: 15 additions & 0 deletions IdentityServer/v7/DPoP/DPoP.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var builder = DistributedApplication.CreateBuilder(args);

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

var api = builder.AddProject<Projects.Api>("api");

builder.AddProject<Projects.WebClient>("webclient")
.WaitFor(idp)
.WaitFor(api);

builder.AddProject<Projects.ClientCredentials>("clientcredentials")
.WaitFor(idp)
.WaitFor(api);

builder.Build().Run();
21 changes: 21 additions & 0 deletions IdentityServer/v7/DPoP/DPoP.AppHost/DPoP.AppHost.csproj
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="..\Api\Api.csproj" />
<ProjectReference Include="..\WebClient\WebClient.csproj" />
<ProjectReference Include="..\ClientCredentials\ClientCredentials.csproj" />
<ProjectReference Include="..\..\IdentityServerHost\src\IdentityServerHost.csproj" />
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions IdentityServer/v7/DPoP/DPoP.AppHost/Properties/launchSettings.json
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: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"
}
}
}
}
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"
}
}
}
9 changes: 9 additions & 0 deletions IdentityServer/v7/DPoP/DPoP.AppHost/appsettings.json
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"
}
}
}
50 changes: 50 additions & 0 deletions IdentityServer/v7/DPoP/DPoP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions IdentityServer/v7/DPoP/WebClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,6 +87,7 @@

var app = builder.Build();

app.MapDefaultEndpoints();
app.UseDeveloperExceptionPage();
app.UseHttpsRedirection();
app.UseStaticFiles();
Expand Down
5 changes: 4 additions & 1 deletion IdentityServer/v7/DPoP/WebClient/WebClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<PackageReference Include="Duende.AccessTokenManagement" />
<PackageReference Include="Duende.AccessTokenManagement.OpenIdConnect" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

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

</Project>
9 changes: 2 additions & 7 deletions IdentityServer/v7/IdentityServerHost/src/HostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

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

</Project>
41 changes: 5 additions & 36 deletions IdentityServer/v7/IdentityServerHost/src/Program.cs
Original file line number Diff line number Diff line change
@@ -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();
5 changes: 4 additions & 1 deletion IdentityServer/v8/DPoP/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<ItemGroup>
<PackageReference Include="Duende.IdentityModel" />
<PackageReference Include="Duende.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

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

</Project>
Loading
Loading