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
2 changes: 1 addition & 1 deletion IdentityServer/v7/TokenExchange/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityModel" Version="7.1.0" />
<PackageReference Include="Duende.IdentityModel" Version="8.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Duende Software. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Buffers.Text;
using System.Diagnostics;
using System.Text;
using System.Text.Json;
Expand All @@ -26,8 +27,8 @@ public static void Show(this TokenResponse response)
var header = parts[0];
var claims = parts[1];

Console.WriteLine(PrettyPrintJson(Encoding.UTF8.GetString(Base64Url.Decode(header))));
Console.WriteLine(PrettyPrintJson(Encoding.UTF8.GetString(Base64Url.Decode(claims))));
Console.WriteLine(PrettyPrintJson(Encoding.UTF8.GetString(Base64Url.DecodeFromChars(header))));
Console.WriteLine(PrettyPrintJson(Encoding.UTF8.GetString(Base64Url.DecodeFromChars(claims))));
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

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

<ItemGroup>
<ProjectReference Include="..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>
</Project>
12 changes: 3 additions & 9 deletions IdentityServer/v7/TokenExchange/IdentityServerHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@

using IdentityServerHost;
using Microsoft.AspNetCore.DataProtection;
using Serilog;
using Serilog.Sinks.SystemConsole.Themes;

Console.Title = "IdentityServer";

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();

var idsvrBuilder = builder.Services.AddIdentityServer()
.AddInMemoryApiScopes(Config.Scopes)
Expand All @@ -36,6 +28,8 @@

var app = builder.Build();

app.MapDefaultEndpoints();

app.UseDeveloperExceptionPage();

app.UseIdentityServer();
Expand Down
5 changes: 5 additions & 0 deletions IdentityServer/v7/TokenExchange/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**Token Exchange Sample**

 This sample requires multiple projects to be run at once. That can easily be done by running the included Aspire AppHost. The Aspire dashboard will show the status of all running applications and show you the links to the running applications. Aspire will also collect the Open Telemetry data (logs, metrics, traces) and make it available on the dashboard.
For the included console application please look at the output of your IDE to see the results.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var builder = DistributedApplication.CreateBuilder(args);

var idsrv = builder.AddProject<Projects.IdentityServerHost>("identityserverhost");
builder.AddProject<Projects.Client>("client")
.WaitFor(idsrv);

builder.Build().Run();
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:17036;http://localhost:15277",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21012",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23192",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22249"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15277",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19284",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18147",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20272"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.1">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>7345a95a-3a14-4c9b-985a-1dac550f4368</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Client\Client.csproj" />
<ProjectReference Include="..\IdentityServerHost\IdentityServerHost.csproj" />
</ItemGroup>

</Project>
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"
}
}
}
28 changes: 28 additions & 0 deletions IdentityServer/v7/TokenExchange/TokenExchange.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServerHost", "Ident
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TokenExchange.AppHost", "TokenExchange.AppHost\TokenExchange.AppHost.csproj", "{EB806040-C123-4877-BE99-8EAE9C8FFAA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.ServiceDefaults", "..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{F85570AF-140B-4006-94DC-2D6DFD7B3231}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +45,30 @@ Global
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x64.Build.0 = Release|Any CPU
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x86.ActiveCfg = Release|Any CPU
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x86.Build.0 = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|x64.ActiveCfg = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|x64.Build.0 = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|x86.ActiveCfg = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Debug|x86.Build.0 = Debug|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|Any CPU.Build.0 = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|x64.ActiveCfg = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|x64.Build.0 = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|x86.ActiveCfg = Release|Any CPU
{EB806040-C123-4877-BE99-8EAE9C8FFAA8}.Release|x86.Build.0 = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|x64.ActiveCfg = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|x64.Build.0 = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|x86.ActiveCfg = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Debug|x86.Build.0 = Debug|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|Any CPU.Build.0 = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|x64.ActiveCfg = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|x64.Build.0 = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|x86.ActiveCfg = Release|Any CPU
{F85570AF-140B-4006-94DC-2D6DFD7B3231}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="8.0.0-alpha.1" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>
</Project>
11 changes: 2 additions & 9 deletions IdentityServer/v8/TokenExchange/IdentityServerHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@

using IdentityServerHost;
using Microsoft.AspNetCore.DataProtection;
using Serilog;
using Serilog.Sinks.SystemConsole.Themes;

Console.Title = "IdentityServer";

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();

var idsvrBuilder = builder.Services.AddIdentityServer()
.AddInMemoryApiScopes(Config.Scopes)
Expand All @@ -38,6 +30,7 @@

app.UseDeveloperExceptionPage();

app.MapDefaultEndpoints();
app.UseIdentityServer();

app.Run();
5 changes: 5 additions & 0 deletions IdentityServer/v8/TokenExchange/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**Token Exchange Sample**

 This sample requires multiple projects to be run at once. That can easily be done by running the included Aspire AppHost. The Aspire dashboard will show the status of all running applications and show you the links to the running applications. Aspire will also collect the Open Telemetry data (logs, metrics, traces) and make it available on the dashboard.
For the included console application please look at the output of your IDE to see the results.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var builder = DistributedApplication.CreateBuilder(args);

var idsrv = builder.AddProject<Projects.IdentityServerHost>("identityserverhost");
builder.AddProject<Projects.Client>("client")
.WaitFor(idsrv);

builder.Build().Run();
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:17036;http://localhost:15277",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21012",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23192",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22249"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15277",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19284",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18147",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20272"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.1">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>7345a95a-3a14-4c9b-985a-1dac550f4368</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Client\Client.csproj" />
<ProjectReference Include="..\IdentityServerHost\IdentityServerHost.csproj" />
</ItemGroup>

</Project>
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"
}
}
}
28 changes: 28 additions & 0 deletions IdentityServer/v8/TokenExchange/TokenExchange.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServerHost", "Ident
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TokenExchange.AppHost", "TokenExchange.AppHost\TokenExchange.AppHost.csproj", "{E90D42B7-BC5B-498C-A667-70F90E8A03CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.ServiceDefaults", "..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +45,30 @@ Global
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x64.Build.0 = Release|Any CPU
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x86.ActiveCfg = Release|Any CPU
{93B5DD40-6D86-4E99-AA89-CBB41F70E40F}.Release|x86.Build.0 = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|x64.ActiveCfg = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|x64.Build.0 = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|x86.ActiveCfg = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Debug|x86.Build.0 = Debug|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|Any CPU.Build.0 = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|x64.ActiveCfg = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|x64.Build.0 = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|x86.ActiveCfg = Release|Any CPU
{E90D42B7-BC5B-498C-A667-70F90E8A03CC}.Release|x86.Build.0 = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|x64.ActiveCfg = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|x64.Build.0 = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|x86.ActiveCfg = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Debug|x86.Build.0 = Debug|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|Any CPU.Build.0 = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|x64.ActiveCfg = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|x64.Build.0 = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|x86.ActiveCfg = Release|Any CPU
{D312D120-217B-4BF2-ADA8-9AEC3BEED25C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions samples.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
<Folder Name="/IdentityServer/v7/TokenExchange/">
<Project Path="IdentityServer/v7/TokenExchange/Client/Client.csproj" />
<Project Path="IdentityServer/v7/TokenExchange/IdentityServerHost/IdentityServerHost.csproj" />
<Project Path="IdentityServer/v7/TokenExchange/TokenExchange.AppHost/TokenExchange.AppHost.csproj" />
</Folder>
<Folder Name="/IdentityServer/v7/UserInteraction/" />
<Folder Name="/IdentityServer/v7/UserInteraction/Ciba/">
Expand Down Expand Up @@ -498,6 +499,7 @@
<Folder Name="/IdentityServer/v8/TokenExchange/">
<Project Path="IdentityServer/v8/TokenExchange/Client/Client.csproj" />
<Project Path="IdentityServer/v8/TokenExchange/IdentityServerHost/IdentityServerHost.csproj" />
<Project Path="IdentityServer/v8/TokenExchange/TokenExchange.AppHost/TokenExchange.AppHost.csproj" />
</Folder>
<Folder Name="/IdentityServer/v8/UserInteraction/" />
<Folder Name="/IdentityServer/v8/UserInteraction/Ciba/">
Expand Down
Loading