Conversation
- 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.
- 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.
- 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.
- 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.
- 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`.
- 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.
- 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.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1241Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1241" |
aaronpowell
left a comment
There was a problem hiding this comment.
Some questions and comments but the main thing is that the client project shouldn't have Hosting in the name (or namespace).
...ityToolkit.Aspire.Hosting.Logto.AppHost/CommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj
Outdated
Show resolved
Hide resolved
| builder.AddServiceDefaults(); | ||
|
|
||
| builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||
| .AddLogtoJwtBearer("logto", "http://localhost:5072/", |
There was a problem hiding this comment.
Shouldn't the endpoint come from Aspire?
There was a problem hiding this comment.
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.
| config.AppId = "s6zda5bqn1qlsjzaiklqn"; | ||
| config.AppSecret = "Df77aDt13MG3nSTgo8eKZP2HdeSfbed0"; |
There was a problem hiding this comment.
I assume these are things that could come from Aspire
There was a problem hiding this comment.
Not directly from Aspire today. These values are Logto client credentials, so they need to come from a Logto application registration first. Aspire can pass them through configuration/secrets, but it doesn't create the Logto application automatically.
It would be possible to automate that through the Logto Management API, but that would add a separate provisioning workflow, which felt out of scope for this sample.
...unityToolkit.Aspire.Hosting.Logto.Client/CommunityToolkit.Aspire.Hosting.Logto.Client.csproj
Outdated
Show resolved
Hide resolved
| <PropertyGroup> | ||
| <Description>.NET Aspire hosting extensions for Logto (includes PostgreSQL and Redis integration).</Description> | ||
| <AdditionalPackageTags>logto redis postgres hosting extensions</AdditionalPackageTags> | ||
| <IsPreview>true</IsPreview> |
There was a problem hiding this comment.
Why are we marking this as preview? Should we be putting Experimental attributes in?
| builderWithResource | ||
| .WithEntrypoint("sh") | ||
| .WithArgs("-c", "npm run cli db seed -- --swe && npm start"); |
There was a problem hiding this comment.
it could be very opaque to the user that the entrypoint is being overridden, what's the reason we do it?
There was a problem hiding this comment.
We override the entrypoint because Logto requires the DB seed step before the app starts in our Aspire scenario, otherwise the container doesn't come up in a usable state. I agree this is not obvious from AddLogtoContainer(), so I can make it explicit either by documenting it clearly or by moving it behind an opt-in method like WithDatabaseSeeding()/WithSeededStartup().
Directory.Packages.props
Outdated
| <<<<<<< 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 |
There was a problem hiding this comment.
Think this is a merge gone bad
…ommunityToolkit.Aspire.Hosting.Logto.AppHost.csproj Co-authored-by: Aaron Powell <me@aaron-powell.com>
…kit.Aspire.Hosting.Logto.Client.csproj Co-authored-by: Aaron Powell <me@aaron-powell.com>
…t and package configuration files
- 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`.
…o JWT configuration - Replaced hardcoded API audience with a `const` string in `Program.cs` for improved readability and maintainability.
Closes #<ISSUE_NUMBER>
PR Checklist
Other information