Skip to content

Commit 2d5e9c5

Browse files
axies20aaronpowellCopilot
authored
Logto (#1241)
* Add Logto with PostgreSQL and Redis integration (#815) - Introduced `CommunityToolkit.Aspire.Hosting.Logto` project for integrating Logto with PostgreSQL and Redis. - Added extension methods for configuring Logto containers, health checks, and resource dependencies. - Created test projects for validating Logto container configuration and health checks. - Added example projects under `examples/logto` showcasing Logto integration with PostgreSQL and Redis. - Updated solution file and package references to include the new Logto project. * Add Logto client hosting support (#817) - Introduced `CommunityToolkit.Aspire.Hosting.Logto.Client` project for integrating Logto client configuration. - Added `LogtoClientBuilder` for seamless setup of Logto client services in `IHostApplicationBuilder`. - Implemented connection string helper for parsing Logto connection strings. - Updated solution and centralized package references to include the new project. * Add Logto Client API example project - Introduced `CommunityToolkit.Aspire.Hosting.Logto.ClientApi` under `examples/logto` to demonstrate Logto client integration. - Added project configuration files (`Program.cs`, `appsettings.json`, `launchSettings.json`) for application setup. - Renamed `AddLogtoClient` to `AddLogtoSDKClient` in `LogtoClientBuilder`. - Updated solution and centralized package references to include the new example project and dependencies. * Add tests and enhancements for Logto Client integration - Introduced a new test project `CommunityToolkit.Aspire.Hosting.Logto.Client.Tests` for validating Logto client behavior. - Added integration and unit tests for `LogtoClientBuilder` and `LogtoConnectionStringHelper`. - Implemented OIDC authentication and JWT bearer support in `LogtoClientBuilder`. - Extended `Program.cs` in `ClientApi` example with authentication routes (`/me`, `/signin`, `/signout`). - Updated dependencies and centralized package references for added functionalities. - Modified project and solution files to include updated references. * Refactor Logto client integration - Updated method names from `AddLogtoSDKClient` to `AddLogtoOIDC` for better alignment with OIDC usage. - Enhanced `AddLogtoOIDC` and `AddLogtoJwtBearer` methods to support additional configuration options. - Added `Microsoft.Extensions.DependencyInjection.Abstractions` package reference to support service registration. - Updated tests to reflect the method renaming and new configuration capabilities. - Extended `Program.cs` in the ClientApi example to include `UseAuthentication` and `UseAuthorization`. - Improved consistency and readability of XML documentation across updated methods. - Centralized package references for additional dependencies in `Directory.Packages.props`. * Remove unused `/signout` route from ClientApi example * Rename `ClientApi` example to `ClientOIDC` and update method signatures - Changed the `ClientApi` project to `ClientOIDC` for better alignment with OIDC standards. - Updated method signatures in `LogtoClientBuilder` to use `appIndeficator` instead of `appId` and support multiple audience identifiers. - Improved XML documentation consistency for updated methods. - Adjusted solution, project references, and configuration files to reflect the renaming and API changes. * Add `ClientJWT` example with Logto JWT authentication support - Introduced `CommunityToolkit.Aspire.Hosting.Logto.ClientJWT` project under `examples/logto` to demonstrate Logto JWT authentication. - Configured authentication and authorization middleware with Logto's JWT Bearer scheme in `Program.cs`. - Added example routes (`/secure` and `/tokens`) for testing secured endpoint access and token retrieval. - Updated `AppHost` to include `ClientJWT` project as a dependency. - Improved XML documentation for `AddLogtoJwtBearer` methods, including updated parameter descriptions and exception handling. * Update examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj Co-authored-by: Aaron Powell <me@aaron-powell.com> * Update src/CommunityToolkit.Aspire.Hosting.Logto.Client/CommunityToolkit.Aspire.Hosting.Logto.Client.csproj Co-authored-by: Aaron Powell <me@aaron-powell.com> * Remove unused package references and resolve merge conflict in project and package configuration files * Update package versions and project SDKs for Logto client integration - Upgraded `Aspire.AppHost.Sdk` from `13.0.0` to `13.2.0` in `examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj`. - Added `Microsoft.AspNetCore.Authentication.JwtBearer` and `Microsoft.AspNetCore.Authentication.OpenIdConnect` package versions to `Directory.Packages.props`. * Update `ClientJWT` example to use a constant for API audience in Logto JWT configuration - Replaced hardcoded API audience with a `const` string in `Program.cs` for improved readability and maintainability. * Remove `<IsPreview>` property from Logto project * Rename `Hosting.Logto.Client` to `Logto.Client` and adjust related references - Renamed `CommunityToolkit.Aspire.Hosting.Logto.Client` to `CommunityToolkit.Aspire.Logto.Client` for improved namespace consistency. - Updated all project, namespace, and solution references to reflect the renaming. - Adjusted example projects (`ClientJWT` and `ClientOIDC`) and `AppHost` references accordingly. * Add `WithDeprecationTracing` method to enable Node.js deprecation tracing in Logto container * Add `Hosting.Logto.Tests` and `Logto.Client.Tests` to test matrix in GitHub Actions * Refactor Logto configuration: introduce validation for Logto options and add support for data volume mapping. * Refactor `AppHostTest` to use `AspireIntegrationTestFixture`; add `AppHost` project reference to test project * Allow null `port` and `adminPort` in `WithResourcePort` to enable random host port assignment. * Update Logto container tag to v1.38 * Refactor `LogtoContainerResource` to `LogtoResource` and update related APIs and tests. Streamline naming for consistency. * Set default HTTP and admin ports in `WithResourcePort` method of `LogtoBuilderExtensions`. * Update examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj * Add Logto integration: introduce `LogtoResource` and client builders with OIDC and JWT Bearer configurations. Update APIs, examples, and tests. * Apply suggestion from @aaronpowell * Fixing build errors * Fix Logto test startup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * not using persisted db This seems to be messing with local dev auth from postgres. * Testing a better endpoint * deleting the generated files * Adding missing README.md --------- Co-authored-by: Aaron Powell <me@aaron-powell.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f8169bb commit 2d5e9c5

34 files changed

Lines changed: 1746 additions & 0 deletions

CommunityToolkit.Aspire.slnx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
<Project Path="examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit.csproj" />
8282
<Project Path="examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults/CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults.csproj" />
8383
</Folder>
84+
<Folder Name="/examples/logto/">
85+
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj" />
86+
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults/CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults.csproj" />
87+
<Project Path="examples/logto/CommunityToolkit.Aspire.Logto.ClientJWT/CommunityToolkit.Aspire.Logto.ClientJWT.csproj" />
88+
<Project Path="examples/logto/CommunityToolkit.Aspire.Logto.ClientOIDC/CommunityToolkit.Aspire.Logto.ClientOIDC.csproj" />
89+
</Folder>
8490
<Folder Name="/examples/mailpit/">
8591
<Project Path="examples/mailpit/CommunityToolkit.Aspire.Hosting.MailPit.AppHost/CommunityToolkit.Aspire.Hosting.MailPit.AppHost.csproj" />
8692
<Project Path="examples/mailpit/CommunityToolkit.Aspire.Hosting.MailPit.SendMailApi/CommunityToolkit.Aspire.Hosting.MailPit.SendMailApi.csproj" />
@@ -219,6 +225,7 @@
219225
<Project Path="src/CommunityToolkit.Aspire.Hosting.k6/CommunityToolkit.Aspire.Hosting.k6.csproj" />
220226
<Project Path="src/CommunityToolkit.Aspire.Hosting.KurrentDB/CommunityToolkit.Aspire.Hosting.KurrentDB.csproj" />
221227
<Project Path="src/CommunityToolkit.Aspire.Hosting.LavinMQ/CommunityToolkit.Aspire.Hosting.LavinMQ.csproj" />
228+
<Project Path="src/CommunityToolkit.Aspire.Hosting.Logto/CommunityToolkit.Aspire.Hosting.Logto.csproj" />
222229
<Project Path="src/CommunityToolkit.Aspire.Hosting.MailPit/CommunityToolkit.Aspire.Hosting.MailPit.csproj" />
223230
<Project Path="src/CommunityToolkit.Aspire.Hosting.McpInspector/CommunityToolkit.Aspire.Hosting.McpInspector.csproj" />
224231
<Project Path="src/CommunityToolkit.Aspire.Hosting.Meilisearch/CommunityToolkit.Aspire.Hosting.Meilisearch.csproj" />
@@ -246,6 +253,7 @@
246253
<Project Path="src/CommunityToolkit.Aspire.Hosting.Zitadel/CommunityToolkit.Aspire.Hosting.Zitadel.csproj" />
247254
<Project Path="src/CommunityToolkit.Aspire.DuckDB.NET.Data/CommunityToolkit.Aspire.DuckDB.NET.Data.csproj" />
248255
<Project Path="src/CommunityToolkit.Aspire.KurrentDB/CommunityToolkit.Aspire.KurrentDB.csproj" />
256+
<Project Path="src/CommunityToolkit.Aspire.Logto.Client/CommunityToolkit.Aspire.Logto.Client.csproj" />
249257
<Project Path="src/CommunityToolkit.Aspire.MassTransit.RabbitMQ/CommunityToolkit.Aspire.MassTransit.RabbitMQ.csproj" />
250258
<Project Path="src/CommunityToolkit.Aspire.Meilisearch/CommunityToolkit.Aspire.Meilisearch.csproj" />
251259
<Project Path="src/CommunityToolkit.Aspire.Microsoft.Data.Sqlite/CommunityToolkit.Aspire.Microsoft.Data.Sqlite.csproj" />
@@ -283,6 +291,7 @@
283291
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions.Tests/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions.Tests.csproj" />
284292
<Project Path="tests/CommunityToolkit.Aspire.Hosting.KurrentDB.Tests/CommunityToolkit.Aspire.Hosting.KurrentDB.Tests.csproj" />
285293
<Project Path="tests/CommunityToolkit.Aspire.Hosting.LavinMQ.Tests/CommunityToolkit.Aspire.Hosting.LavinMQ.Tests.csproj" />
294+
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Logto.Tests/CommunityToolkit.Aspire.Hosting.Logto.Tests.csproj" />
286295
<Project Path="tests/CommunityToolkit.Aspire.Hosting.MailPit.Tests/CommunityToolkit.Aspire.Hosting.MailPit.Tests.csproj" />
287296
<Project Path="tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests.csproj" />
288297
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Meilisearch.Tests/CommunityToolkit.Aspire.Hosting.Meilisearch.Tests.csproj" />
@@ -309,6 +318,7 @@
309318
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Zitadel.Tests/CommunityToolkit.Aspire.Hosting.Zitadel.Tests.csproj" />
310319
<Project Path="tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests.csproj" />
311320
<Project Path="tests/CommunityToolkit.Aspire.KurrentDB.Tests/CommunityToolkit.Aspire.KurrentDB.Tests.csproj" />
321+
<Project Path="tests/CommunityToolkit.Aspire.Logto.Client.Tests/CommunityToolkit.Aspire.Logto.Client.Tests.csproj" />
312322
<Project Path="tests/CommunityToolkit.Aspire.MassTransit.RabbitMQ.Tests/CommunityToolkit.Aspire.MassTransit.RabbitMQ.Tests.csproj" />
313323
<Project Path="tests/CommunityToolkit.Aspire.Meilisearch.Tests/CommunityToolkit.Aspire.Meilisearch.Tests.csproj" />
314324
<Project Path="tests/CommunityToolkit.Aspire.Microsoft.Data.Sqlite.Tests/CommunityToolkit.Aspire.Microsoft.Data.Sqlite.Tests.csproj" />

Directory.Packages.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
<PackageVersion Include="Aspire.Hosting.MongoDB" Version="$(AspireVersion)" />
2323
<PackageVersion Include="Aspire.Hosting.MySql" Version="$(AspireVersion)" />
2424
<PackageVersion Include="Aspire.Hosting.SqlServer" Version="$(AspireVersion)" />
25+
<PackageVersion Include="Logto.AspNetCore.Authentication" Version="0.2.0" />
2526
<PackageVersion Include="AspNetCore.HealthChecks.Network" Version="9.0.0" />
27+
2628
</ItemGroup>
2729
<ItemGroup Label="Core Packages">
2830
<!-- AspNetCore packages -->
@@ -34,6 +36,8 @@
3436
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="9.0.0" />
3537
<PackageVersion Include="Dapr.AspNetCore" Version="1.15.3" />
3638
<PackageVersion Include="Dapr.Client" Version="1.15.3" />
39+
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.16" />
40+
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.16" />
3741
<PackageVersion Include="Microsoft.AspNetCore.Components.QuickGrid" Version="$(AspNetCoreVersion)" />
3842
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.20" />
3943
<PackageVersion Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var builder = DistributedApplication.CreateBuilder(args);
2+
3+
var postgres = builder.AddPostgres("postgres");
4+
5+
var cache = builder.AddRedis("redis");
6+
7+
var logto = builder.AddLogto("logto", postgres)
8+
.WithRedis(cache)
9+
.WithDatabaseSeeding();
10+
11+
12+
var clientOIDC = builder.AddProject<Projects.CommunityToolkit_Aspire_Logto_ClientOIDC>("clientOIDC")
13+
.WithReference(logto)
14+
.WaitFor(logto);
15+
var clientJWT = builder.AddProject<Projects.CommunityToolkit_Aspire_Logto_ClientJWT>("clientJWT")
16+
.WithReference(logto)
17+
.WaitFor(logto);
18+
19+
20+
builder.Build().Run();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Aspire.AppHost.Sdk/13.4.3">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Logto\CommunityToolkit.Aspire.Hosting.Logto.csproj"
11+
IsAspireProjectResource="false" />
12+
<ProjectReference Include="..\CommunityToolkit.Aspire.Logto.ClientJWT\CommunityToolkit.Aspire.Logto.ClientJWT.csproj" />
13+
<ProjectReference Include="..\CommunityToolkit.Aspire.Logto.ClientOIDC\CommunityToolkit.Aspire.Logto.ClientOIDC.csproj" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
18+
<PackageReference Include="Aspire.Hosting.Redis" />
19+
</ItemGroup>
20+
21+
</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:17139;http://localhost:15140",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21242",
13+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23087",
14+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22172"
15+
}
16+
},
17+
"http": {
18+
"commandName": "Project",
19+
"dotnetRunMessages": true,
20+
"launchBrowser": true,
21+
"applicationUrl": "http://localhost:15140",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development",
24+
"DOTNET_ENVIRONMENT": "Development",
25+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19078",
26+
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18181",
27+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20004"
28+
}
29+
}
30+
}
31+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<ItemGroup>
4+
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
5+
6+
<PackageReference Include="Microsoft.Extensions.Http.Resilience"/>
7+
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
8+
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol"/>
9+
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
10+
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
11+
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
12+
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime"/>
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Diagnostics.HealthChecks;
5+
using Microsoft.Extensions.Logging;
6+
using Microsoft.Extensions.ServiceDiscovery;
7+
using OpenTelemetry;
8+
using OpenTelemetry.Metrics;
9+
using OpenTelemetry.Trace;
10+
11+
namespace Microsoft.Extensions.Hosting;
12+
13+
// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
14+
// This project should be referenced by each service project in your solution.
15+
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
16+
public static class Extensions
17+
{
18+
private const string HealthEndpointPath = "/health";
19+
private const string AlivenessEndpointPath = "/alive";
20+
21+
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
22+
{
23+
builder.ConfigureOpenTelemetry();
24+
25+
builder.AddDefaultHealthChecks();
26+
27+
builder.Services.AddServiceDiscovery();
28+
29+
builder.Services.ConfigureHttpClientDefaults(http =>
30+
{
31+
// Turn on resilience by default
32+
http.AddStandardResilienceHandler();
33+
34+
// Turn on service discovery by default
35+
http.AddServiceDiscovery();
36+
});
37+
38+
// Uncomment the following to restrict the allowed schemes for service discovery.
39+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
40+
// {
41+
// options.AllowedSchemes = ["https"];
42+
// });
43+
44+
return builder;
45+
}
46+
47+
public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
48+
where TBuilder : IHostApplicationBuilder
49+
{
50+
builder.Logging.AddOpenTelemetry(logging =>
51+
{
52+
logging.IncludeFormattedMessage = true;
53+
logging.IncludeScopes = true;
54+
});
55+
56+
builder.Services.AddOpenTelemetry()
57+
.WithMetrics(metrics =>
58+
{
59+
metrics.AddAspNetCoreInstrumentation()
60+
.AddHttpClientInstrumentation()
61+
.AddRuntimeInstrumentation();
62+
})
63+
.WithTracing(tracing =>
64+
{
65+
tracing.AddSource(builder.Environment.ApplicationName)
66+
.AddAspNetCoreInstrumentation(tracing =>
67+
// Exclude health check requests from tracing
68+
tracing.Filter = context =>
69+
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
70+
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
71+
)
72+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
73+
//.AddGrpcClientInstrumentation()
74+
.AddHttpClientInstrumentation();
75+
});
76+
77+
builder.AddOpenTelemetryExporters();
78+
79+
return builder;
80+
}
81+
82+
private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder)
83+
where TBuilder : IHostApplicationBuilder
84+
{
85+
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
86+
87+
if (useOtlpExporter)
88+
{
89+
builder.Services.AddOpenTelemetry().UseOtlpExporter();
90+
}
91+
92+
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
93+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
94+
//{
95+
// builder.Services.AddOpenTelemetry()
96+
// .UseAzureMonitor();
97+
//}
98+
99+
return builder;
100+
}
101+
102+
public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder)
103+
where TBuilder : IHostApplicationBuilder
104+
{
105+
builder.Services.AddHealthChecks()
106+
// Add a default liveness check to ensure app is responsive
107+
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
108+
109+
return builder;
110+
}
111+
112+
public static WebApplication MapDefaultEndpoints(this WebApplication app)
113+
{
114+
// Adding health checks endpoints to applications in non-development environments has security implications.
115+
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
116+
if (app.Environment.IsDevelopment())
117+
{
118+
// All health checks must pass for app to be considered ready to accept traffic after starting
119+
app.MapHealthChecks(HealthEndpointPath);
120+
121+
// Only health checks tagged with the "live" tag must pass for app to be considered alive
122+
app.MapHealthChecks(AlivenessEndpointPath,
123+
new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") });
124+
}
125+
126+
return app;
127+
}
128+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@CommunityToolkit.Aspire.Hosting.Logto.ClientJWT_HostAddress = http://localhost:5072
2+
3+
GET {{CommunityToolkit.Aspire.Hosting.Logto.ClientJWT_HostAddress}}/
4+
Accept: application/json
5+
6+
###
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<ItemGroup>
4+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer"/>
5+
</ItemGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Logto.Client\CommunityToolkit.Aspire.Logto.Client.csproj" />
9+
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults.csproj" />
10+
</ItemGroup>
11+
12+
</Project>

0 commit comments

Comments
 (0)