Skip to content
Open

Logto #1241

Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cd63a59
Add Logto with PostgreSQL and Redis integration (#815)
axies20 Nov 30, 2025
0daa9ae
Add Logto client hosting support (#817)
axies20 Dec 1, 2025
34b16e2
Add Logto Client API example project
axies20 Dec 2, 2025
9c725dd
Add tests and enhancements for Logto Client integration
axies20 Dec 3, 2025
60f73e9
Refactor Logto client integration
axies20 Dec 6, 2025
8a0f9de
Remove unused `/signout` route from ClientApi example
axies20 Dec 6, 2025
95d01da
Rename `ClientApi` example to `ClientOIDC` and update method signatures
axies20 Dec 7, 2025
541111c
Add `ClientJWT` example with Logto JWT authentication support
axies20 Dec 7, 2025
bc8b00c
Merge branch 'main' into Logto
axies20 Mar 27, 2026
d4378b3
Update examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost/C…
axies20 Mar 30, 2026
4557bf8
Update src/CommunityToolkit.Aspire.Hosting.Logto.Client/CommunityTool…
axies20 Mar 30, 2026
0e3f42c
Merge branch 'main' into Logto
axies20 Mar 30, 2026
3976aec
Remove unused package references and resolve merge conflict in projec…
axies20 Mar 30, 2026
6685b60
Update package versions and project SDKs for Logto client integration
axies20 Mar 30, 2026
cde0cbd
Update `ClientJWT` example to use a constant for API audience in Logt…
axies20 Mar 30, 2026
d271f0a
Remove `<IsPreview>` property from Logto project
axies20 Mar 30, 2026
f282231
Rename `Hosting.Logto.Client` to `Logto.Client` and adjust related re…
axies20 Mar 31, 2026
a2e300c
Add `WithDeprecationTracing` method to enable Node.js deprecation tra…
axies20 Mar 31, 2026
97ce6d6
Merge branch 'main' into Logto
axies20 Apr 2, 2026
63356b8
Add `Hosting.Logto.Tests` and `Logto.Client.Tests` to test matrix in …
axies20 Apr 2, 2026
20f300b
Refactor Logto configuration: introduce validation for Logto options …
axies20 Apr 15, 2026
cbd16a8
Refactor `AppHostTest` to use `AspireIntegrationTestFixture`; add `Ap…
axies20 Apr 15, 2026
907c4d5
Allow null `port` and `adminPort` in `WithResourcePort` to enable ran…
axies20 Apr 15, 2026
bac366e
Update Logto container tag to v1.38
axies20 Apr 17, 2026
95c6f2c
Refactor `LogtoContainerResource` to `LogtoResource` and update relat…
axies20 Apr 17, 2026
231ae98
Set default HTTP and admin ports in `WithResourcePort` method of `Log…
axies20 Apr 17, 2026
6bfd3ca
Merge branch 'main' into Logto
axies20 May 12, 2026
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
10 changes: 10 additions & 0 deletions CommunityToolkit.Aspire.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
<Project Path="examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit.csproj" />
<Project Path="examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults/CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults.csproj" />
</Folder>
<Folder Name="/examples/logto/">
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.AppHost/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj" />
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.ClientJWT/CommunityToolkit.Aspire.Hosting.Logto.ClientJWT.csproj" />
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.ClientOIDC/CommunityToolkit.Aspire.Hosting.Logto.ClientOIDC.csproj" />
<Project Path="examples/logto/CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults/CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults.csproj" />
</Folder>
<Folder Name="/examples/mailpit/">
<Project Path="examples/mailpit/CommunityToolkit.Aspire.Hosting.MailPit.AppHost/CommunityToolkit.Aspire.Hosting.MailPit.AppHost.csproj" />
<Project Path="examples/mailpit/CommunityToolkit.Aspire.Hosting.MailPit.SendMailApi/CommunityToolkit.Aspire.Hosting.MailPit.SendMailApi.csproj" />
Expand Down Expand Up @@ -214,6 +220,8 @@
<Project Path="src/CommunityToolkit.Aspire.Hosting.k6/CommunityToolkit.Aspire.Hosting.k6.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.KurrentDB/CommunityToolkit.Aspire.Hosting.KurrentDB.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.LavinMQ/CommunityToolkit.Aspire.Hosting.LavinMQ.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.Logto.Client/CommunityToolkit.Aspire.Hosting.Logto.Client.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.Logto/CommunityToolkit.Aspire.Hosting.Logto.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.MailPit/CommunityToolkit.Aspire.Hosting.MailPit.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.McpInspector/CommunityToolkit.Aspire.Hosting.McpInspector.csproj" />
<Project Path="src/CommunityToolkit.Aspire.Hosting.Meilisearch/CommunityToolkit.Aspire.Hosting.Meilisearch.csproj" />
Expand Down Expand Up @@ -276,6 +284,8 @@
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions.Tests/CommunityToolkit.Aspire.Hosting.Keycloak.Extensions.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.KurrentDB.Tests/CommunityToolkit.Aspire.Hosting.KurrentDB.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.LavinMQ.Tests/CommunityToolkit.Aspire.Hosting.LavinMQ.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Logto.Client.Tests/CommunityToolkit.Aspire.Hosting.Logto.Client.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Logto.Tests/CommunityToolkit.Aspire.Hosting.Logto.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.MailPit.Tests/CommunityToolkit.Aspire.Hosting.MailPit.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests.csproj" />
<Project Path="tests/CommunityToolkit.Aspire.Hosting.Meilisearch.Tests/CommunityToolkit.Aspire.Hosting.Meilisearch.Tests.csproj" />
Expand Down
9 changes: 9 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@
<PackageVersion Include="Aspire.Hosting.MongoDB" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.MySql" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.SqlServer" Version="$(AspireVersion)" />
<<<<<<< Logto
<PackageVersion Include="Logto.AspNetCore.Authentication" Version="0.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication" Version="2.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
=======
<PackageVersion Include="AspNetCore.HealthChecks.Network" Version="9.0.0" />
>>>>>>> main
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is a merge gone bad

</ItemGroup>
<ItemGroup Label="Core Packages">
<!-- AspNetCore packages -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using CommunityToolkit.Aspire.Hosting.Logto;

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres")
.WithDataVolume();

var cache = builder.AddRedis("redis")
.WithDataVolume();

var logto = builder.AddLogtoContainer("logto", postgres)
.WithRedis(cache);


var clientOIDC = builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Logto_ClientOIDC>("clientOIDC")
.WithReference(logto)
.WaitFor(logto);
var clientJWT = builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Logto_ClientJWT>("clientJWT")
.WithReference(logto)
.WaitFor(logto);


builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Aspire.AppHost.Sdk/13.0.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
Comment thread
axies20 marked this conversation as resolved.
Outdated
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Logto\CommunityToolkit.Aspire.Hosting.Logto.csproj"
IsAspireProjectResource="false" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.Logto.ClientJWT\CommunityToolkit.Aspire.Hosting.Logto.ClientJWT.csproj" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.Logto.ClientOIDC\CommunityToolkit.Aspire.Hosting.Logto.ClientOIDC.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
<PackageReference Include="Aspire.Hosting.Redis" />
</ItemGroup>

</Project>
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:17139;http://localhost:15140",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21242",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23087",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22172"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15140",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19078",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18181",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20004"
}
}
}
}
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"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Logto.Client\CommunityToolkit.Aspire.Hosting.Logto.Client.csproj" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@CommunityToolkit.Aspire.Hosting.Logto.ClientJWT_HostAddress = http://localhost:5072

GET {{CommunityToolkit.Aspire.Hosting.Logto.ClientJWT_HostAddress}}/weatherforecast/
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using CommunityToolkit.Aspire.Hosting.Logto.Client;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddLogtoJwtBearer("logto", "http://localhost:5072/",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the endpoint come from Aspire?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. logto is the Aspire resource name, so the endpoint is resolved from Aspire via .WithReference(logto). The second parameter is the JWT appIdentification/audience, not the Logto endpoint, so I updated the sample to make that clearer.

configureOptions: opt =>
{
opt.RequireHttpsMetadata = false;
});

builder.Services.AddAuthorization();


var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/", () => "OK");

app.MapGet("/secure", [Authorize] (System.Security.Claims.ClaimsPrincipal user) =>
{
return new
{
user.Identity?.Name,
Claims = user.Claims.Select(c => new { c.Type, c.Value })
};
});


app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5072",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7138;http://localhost:5072",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@CommunityToolkit.Aspire.Hosting.Logto.Client_HostAddress = http://localhost:5137

GET {{CommunityToolkit.Aspire.Hosting.Logto.Client_HostAddress}}/weatherforecast/
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RootNamespace>CommunityToolkit.Aspire.Hosting.Logto.Client</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Logto.Client\CommunityToolkit.Aspire.Hosting.Logto.Client.csproj" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults\CommunityToolkit.Aspire.Hosting.Logto.ServiceDefaults.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using CommunityToolkit.Aspire.Hosting.Logto.Client;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using System.Security.Claims;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();

builder.AddLogtoOIDC("logto", logtoOptions: config =>
{
config.AppId = "s6zda5bqn1qlsjzaiklqn";
config.AppSecret = "Df77aDt13MG3nSTgo8eKZP2HdeSfbed0";

},oidcOptions: opt =>
{
opt.RequireHttpsMetadata = false;
});
builder.Services.AddAuthorization();

var app = builder.Build();


app.UseAuthentication();
app.UseAuthorization();




app.MapGet("/", () => "Hello World!");

app.MapGet("/me",
[Authorize](ClaimsPrincipal user) => new
{
Name = user.Identity?.Name,
IsAuthenticated = user.Identity?.IsAuthenticated ?? false,
Claims = user.Claims.Select(c => new { c.Type, c.Value })
})
.WithName("Me");

app.MapGet("/signin", async context =>
{
if (!(context.User?.Identity?.IsAuthenticated ?? false))
{
await context.ChallengeAsync(new AuthenticationProperties { RedirectUri = "/me" });
}
else
{
context.Response.Redirect("/me");
}
});
app.MapGet("/tokens", [Authorize] async (HttpContext ctx) =>
{
var accessToken = await ctx.GetTokenAsync("access_token");
var idToken = await ctx.GetTokenAsync("id_token");
var refreshToken = await ctx.GetTokenAsync("refresh_token");

return Results.Ok(new
{
access_token = accessToken,
id_token = idToken,
refresh_token = refreshToken
});
});

app.MapGet("/signout", async context =>
{
if (context.User?.Identity?.IsAuthenticated ?? false)
{
await context.SignOutAsync(new AuthenticationProperties { RedirectUri = "/" });
}
else
{
context.Response.Redirect("/");
}
});
app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5137",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7288;http://localhost:5137",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>

<PackageReference Include="Microsoft.Extensions.Http.Resilience"/>
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime"/>
</ItemGroup>

</Project>
Loading
Loading