Skip to content

Commit b0afd93

Browse files
RolandGuijtroland
andauthored
Add Aspire to DynamicProviders sample (#322)
Co-authored-by: roland <roland.guijt@gmail.com>
1 parent 07d668b commit b0afd93

23 files changed

Lines changed: 200 additions & 51 deletions

File tree

IdentityServer/v7/UserInteraction/DynamicProviders/Client/Client.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
</PropertyGroup>
77

88

9+
<ItemGroup>
10+
<ProjectReference Include="..\..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
11+
</ItemGroup>
912
<ItemGroup>
1013
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
1114
<PackageReference Include="Duende.IdentityModel" />

IdentityServer/v7/UserInteraction/DynamicProviders/Client/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Console.Title = "Client";
99

1010
var builder = WebApplication.CreateBuilder(args);
11+
builder.AddServiceDefaults();
1112

1213
builder.Services.AddControllersWithViews();
1314

@@ -62,6 +63,7 @@
6263
app.UseAuthentication();
6364
app.UseAuthorization();
6465

66+
app.MapDefaultEndpoints();
6567
app.MapDefaultControllerRoute().RequireAuthorization();
6668

6769
app.Run();

IdentityServer/v7/UserInteraction/DynamicProviders/DynamicProviders.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServerHost", "Ident
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{85CD36E8-3402-443B-859A-72E4B9390E8B}"
99
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.AppHost", "IdentityServer.AppHost\IdentityServer.AppHost.csproj", "{E8BA4D90-0AF7-4FA3-9F0D-5A11D98C0640}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.ServiceDefaults", "..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{4259ED99-4121-4E62-83C5-CC0699BC389A}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +25,14 @@ Global
2125
{85CD36E8-3402-443B-859A-72E4B9390E8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{85CD36E8-3402-443B-859A-72E4B9390E8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
2327
{85CD36E8-3402-443B-859A-72E4B9390E8B}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{E8BA4D90-0AF7-4FA3-9F0D-5A11D98C0640}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{E8BA4D90-0AF7-4FA3-9F0D-5A11D98C0640}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{E8BA4D90-0AF7-4FA3-9F0D-5A11D98C0640}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{E8BA4D90-0AF7-4FA3-9F0D-5A11D98C0640}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{4259ED99-4121-4E62-83C5-CC0699BC389A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{4259ED99-4121-4E62-83C5-CC0699BC389A}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{4259ED99-4121-4E62-83C5-CC0699BC389A}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{4259ED99-4121-4E62-83C5-CC0699BC389A}.Release|Any CPU.Build.0 = Release|Any CPU
2436
EndGlobalSection
2537
GlobalSection(SolutionProperties) = preSolution
2638
HideSolutionNode = FALSE
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var builder = DistributedApplication.CreateBuilder(args);
2+
var idsvr = builder.AddProject<Projects.IdentityServerHost>("identityserverhost");
3+
builder.AddProject<Projects.Client>("client")
4+
.WaitFor(idsvr);
5+
builder.Build().Run();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Aspire.Hosting.AppHost" />
10+
<ProjectReference Include="..\Client\Client.csproj" />
11+
<ProjectReference Include="..\IdentityServerHost\IdentityServerHost.csproj" />
12+
</ItemGroup>
13+
</Project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17196;http://localhost:15048",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21100",
13+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23036",
14+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22230"
15+
}
16+
},
17+
"http": {
18+
"commandName": "Project",
19+
"dotnetRunMessages": true,
20+
"launchBrowser": true,
21+
"applicationUrl": "http://localhost:15048",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development",
24+
"DOTNET_ENVIRONMENT": "Development",
25+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19122",
26+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18210",
27+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20059"
28+
}
29+
}
30+
}
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}

IdentityServer/v7/UserInteraction/DynamicProviders/IdentityServerHost/IdentityServerHost.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<ProjectReference Include="..\..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
10+
</ItemGroup>
811
<ItemGroup>
912
<PackageReference Include="Duende.IdentityServer.EntityFramework" />
10-
<PackageReference Include="Microsoft.AspNetCore.Authentication.WsFederation" />
11-
<PackageReference Include="Serilog.AspNetCore" />
1213
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
1314
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
1415
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" >

IdentityServer/v7/UserInteraction/DynamicProviders/IdentityServerHost/Program.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,32 @@
55
using IdentityServerHost;
66
using Microsoft.AspNetCore.DataProtection;
77
using Microsoft.EntityFrameworkCore;
8-
using Serilog;
9-
using Serilog.Sinks.SystemConsole.Themes;
108

119
Console.Title = "IdentityServer";
1210

13-
Log.Logger = new LoggerConfiguration()
14-
.MinimumLevel.Information()
15-
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
16-
.CreateLogger();
17-
1811
var seed = args.Contains("/seed");
1912
if (seed)
2013
{
2114
args = args.Except(new[] { "/seed" }).ToArray();
2215
}
2316

2417
var builder = WebApplication.CreateBuilder(args);
25-
26-
builder.Services.AddSerilog();
18+
builder.AddServiceDefaults();
2719

2820
builder.Services.AddRazorPages();
2921

3022
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
3123

3224
if (seed)
3325
{
34-
Log.Information("Seeding database...");
26+
Console.WriteLine("Seeding database...");
3527
SeedData.EnsureSeedData(connectionString);
36-
Log.Information("Done seeding database.");
28+
Console.WriteLine("Done seeding database.");
3729
return;
3830
}
3931

4032
builder.Services.AddIdentityServer(options =>
4133
{
42-
options.Events.RaiseErrorEvents = true;
43-
options.Events.RaiseInformationEvents = true;
44-
options.Events.RaiseFailureEvents = true;
45-
options.Events.RaiseSuccessEvents = true;
46-
4734
// see https://docs.duendesoftware.com/identityserver/fundamentals/resources
4835
options.EmitStaticAudienceClaim = true;
4936

@@ -106,6 +93,7 @@
10693
app.UseRouting();
10794
app.UseIdentityServer();
10895
app.UseAuthorization();
96+
app.MapDefaultEndpoints();
10997
app.MapRazorPages();
11098

11199
app.Run();

0 commit comments

Comments
 (0)