Skip to content

Commit 96dedca

Browse files
RolandGuijtRoland Guijt
andauthored
Aspire for AspNetIdentityPasskeys sample + include a client (#351)
Co-authored-by: Roland Guijt <roland.guijt@duendesoftware.com>
1 parent 4a06d1c commit 96dedca

125 files changed

Lines changed: 80604 additions & 180 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var builder = DistributedApplication.CreateBuilder(args);
2+
3+
var idp = builder.AddProject<Projects.IdentityServerAspNetIdentityPasskeys>("identityserver");
4+
5+
idp.WithCommand(
6+
name: "seed",
7+
displayName: "Seed Database",
8+
executeCommand: async (context) =>
9+
{
10+
var projectMetadata = idp.Resource.GetProjectMetadata();
11+
var projectPath = projectMetadata.ProjectPath;
12+
var process = new System.Diagnostics.Process
13+
{
14+
StartInfo = new System.Diagnostics.ProcessStartInfo
15+
{
16+
FileName = "dotnet",
17+
Arguments = $"run --project \"{projectPath}\" --no-build -- /seed",
18+
UseShellExecute = false,
19+
RedirectStandardOutput = true,
20+
RedirectStandardError = true,
21+
CreateNoWindow = true
22+
}
23+
};
24+
25+
process.Start();
26+
await process.WaitForExitAsync(context.CancellationToken);
27+
28+
if (process.ExitCode == 0)
29+
{
30+
return CommandResults.Success();
31+
}
32+
else
33+
{
34+
var error = await process.StandardError.ReadToEndAsync();
35+
return CommandResults.Failure(error);
36+
}
37+
},
38+
commandOptions: new CommandOptions
39+
{
40+
IconName = "DatabaseArrowUp",
41+
IsHighlighted = true
42+
});
43+
44+
builder.AddProject<Projects.Client>("client")
45+
.WaitFor(idp);
46+
47+
builder.Build().Run();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
</ItemGroup>
11+
<ItemGroup>
12+
<ProjectReference Include="..\IdentityServerAspNetIdentityPasskeys\IdentityServerAspNetIdentityPasskeys.csproj" />
13+
<ProjectReference Include="..\Client\Client.csproj" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:15237",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:21137",
12+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:22137"
13+
}
14+
},
15+
"https": {
16+
"commandName": "Project",
17+
"dotnetRunMessages": true,
18+
"launchBrowser": true,
19+
"applicationUrl": "https://localhost:17237;http://localhost:15237",
20+
"environmentVariables": {
21+
"ASPNETCORE_ENVIRONMENT": "Development",
22+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21137",
23+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22137"
24+
}
25+
}
26+
}
27+
}
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.DistributedApplication": "Information"
7+
}
8+
}
9+
}
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.DistributedApplication": "Information"
7+
}
8+
}
9+
}

‎IdentityServer/v7/AspNetIdentityPasskeys/AspNetIdentityPasskeys.sln‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,76 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{0BF13ED9-61A5-4D
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{2D99DC4E-FF98-48C7-B897-E4C6F0CE42A0}"
1111
ProjectSection(SolutionItems) = preProject
12-
dotnet-tools.json = .config/dotnet-tools.json
12+
dotnet-tools.json = dotnet-tools.json
1313
EndProjectSection
1414
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}"
16+
EndProject
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.ServiceDefaults", "..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{7933C9B2-E155-4892-B375-2A3E7036E502}"
18+
EndProject
19+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetIdentityPasskeys.AppHost", "AspNetIdentityPasskeys.AppHost\AspNetIdentityPasskeys.AppHost.csproj", "{C01F5EE2-1B42-4320-A830-783C44DFA5A1}"
20+
EndProject
1521
Global
1622
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1723
Debug|Any CPU = Debug|Any CPU
24+
Debug|x64 = Debug|x64
25+
Debug|x86 = Debug|x86
1826
Release|Any CPU = Release|Any CPU
27+
Release|x64 = Release|x64
28+
Release|x86 = Release|x86
1929
EndGlobalSection
2030
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2131
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2232
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|x64.ActiveCfg = Debug|Any CPU
34+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|x64.Build.0 = Debug|Any CPU
35+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|x86.ActiveCfg = Debug|Any CPU
36+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Debug|x86.Build.0 = Debug|Any CPU
2337
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|Any CPU.ActiveCfg = Release|Any CPU
2438
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|x64.ActiveCfg = Release|Any CPU
40+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|x64.Build.0 = Release|Any CPU
41+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|x86.ActiveCfg = Release|Any CPU
42+
{BFF3D2A2-391A-477F-81DE-9A2ED321C41C}.Release|x86.Build.0 = Release|Any CPU
43+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
45+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|x64.ActiveCfg = Debug|Any CPU
46+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|x64.Build.0 = Debug|Any CPU
47+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|x86.ActiveCfg = Debug|Any CPU
48+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Debug|x86.Build.0 = Debug|Any CPU
49+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|Any CPU.Build.0 = Release|Any CPU
51+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|x64.ActiveCfg = Release|Any CPU
52+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|x64.Build.0 = Release|Any CPU
53+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|x86.ActiveCfg = Release|Any CPU
54+
{2C00CA4C-C6DD-47D9-878F-82A825B5CAF3}.Release|x86.Build.0 = Release|Any CPU
55+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|Any CPU.Build.0 = Debug|Any CPU
57+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|x64.ActiveCfg = Debug|Any CPU
58+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|x64.Build.0 = Debug|Any CPU
59+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|x86.ActiveCfg = Debug|Any CPU
60+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Debug|x86.Build.0 = Debug|Any CPU
61+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|Any CPU.ActiveCfg = Release|Any CPU
62+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|Any CPU.Build.0 = Release|Any CPU
63+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|x64.ActiveCfg = Release|Any CPU
64+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|x64.Build.0 = Release|Any CPU
65+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|x86.ActiveCfg = Release|Any CPU
66+
{7933C9B2-E155-4892-B375-2A3E7036E502}.Release|x86.Build.0 = Release|Any CPU
67+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
69+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|x64.ActiveCfg = Debug|Any CPU
70+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|x64.Build.0 = Debug|Any CPU
71+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|x86.ActiveCfg = Debug|Any CPU
72+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Debug|x86.Build.0 = Debug|Any CPU
73+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
74+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|x64.ActiveCfg = Release|Any CPU
76+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|x64.Build.0 = Release|Any CPU
77+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|x86.ActiveCfg = Release|Any CPU
78+
{C01F5EE2-1B42-4320-A830-783C44DFA5A1}.Release|x86.Build.0 = Release|Any CPU
79+
EndGlobalSection
80+
GlobalSection(SolutionProperties) = preSolution
81+
HideSolutionNode = FALSE
2582
EndGlobalSection
2683
GlobalSection(NestedProjects) = preSolution
2784
{2D99DC4E-FF98-48C7-B897-E4C6F0CE42A0} = {0BF13ED9-61A5-4DAC-9E47-E2D0372F8DF6}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>true</ImplicitUsings>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) Duende Software. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using System.Diagnostics;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace Client.Pages;
9+
10+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
11+
[IgnoreAntiforgeryToken]
12+
public class ErrorModel : PageModel
13+
{
14+
public string RequestId { get; set; }
15+
16+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
17+
18+
private readonly ILogger<ErrorModel> _logger;
19+
20+
public ErrorModel(ILogger<ErrorModel> logger)
21+
{
22+
_logger = logger;
23+
}
24+
25+
public void OnGet()
26+
{
27+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
28+
}
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="text-center">
8+
<h1 class="display-4">Welcome</h1>
9+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
10+
</div>
11+

0 commit comments

Comments
 (0)