Add Aspire hosting extension for AuthProxy - #48
Conversation
Introduces Source/Aspire — a dedicated Aspire hosting integration library that lets any Aspire AppHost wire up AuthProxy with a fluent, idiomatic API. New files: - Source/Aspire/Aspire.csproj - Source/Aspire/GlobalUsings.cs - Source/Aspire/AuthProxyResource.cs – ContainerResource for cratis/authproxy - Source/Aspire/AuthProxyConfigAnnotation.cs – per-resource annotation for index tracking - Source/Aspire/OidcProviderType.cs – provider brand enum (mirrors Configuration counterpart) - Source/Aspire/AuthProxyExtensions.cs – AddAuthProxy + full fluent configuration API Updated files: - AuthProxy.slnx – adds Aspire project - Directory.Packages.props – pins Aspire.Hosting 9.5.2 - Source/Composition/Composition.csproj – references Aspire library (IsAspireProjectResource=false) - Source/Composition/AppHost.cs – uses new WithBackend/WithFrontend extension methods
|
@copilot Great, add documentation and also add NuGet publishing to the publish workflow using trusted publishing (see here for inspiration https://github.com/Cratis/Arc/blob/main/.github/workflows/publish.yml). We do not want any other projects to publish to NuGet, only the Aspire one. |
Done in the latest commit. Here's what was added: Documentation (
NuGet publishing (
|
|
@copilot We also need to add support for the entire invites system; And Tenant selection: https://github.com/Cratis/AuthProxy/blob/main/Documentation/configuration/tenant-selection.md |
... Done in the latest commit. Here's what was added:
authproxy.WithSelectionTenantResolution("https://platform.example.com/api/tenants/selectable");Invite system — four new methods:
|
|
@copilot We also need to be able to configure services for resolving identity details: (https://github.com/Cratis/AuthProxy/blob/main/Documentation/configuration/services.md). And, not sure if this is covered, but setting the different endpoints the auth proxy should call (tenant verification ++) - it would be nice to then use a reference to which other service holds it and then the route on it and then automatically internally we resolve that - so we don't have to put in the full http:// addresses. |
Done in the latest commit. Here's what was added: Identity details resolution — authproxy.WithBackend("reporting", reportingApi, resolveIdentityDetails: false)Resource-based endpoint overloads — three methods now have a second overload that takes an
Example: authproxy
.WithTenantVerification(platformApi, "/api/tenants/{tenantId}")
.WithSelectionTenantResolution(platformApi, "/api/tenants/selectable")
.WithInvite(publicKeyPem, studioApi, "/internal/invites/exchange", issuer: "...");The string-based overloads are unchanged for callers that don't use Aspire resources. |
Adds a dedicated Aspire hosting integration library so any Aspire AppHost can add and configure AuthProxy with a fluent, idiomatic API — either as a container resource (external consumers) or layered on top of a
ProjectResource(in-repo development).Added
Source/Aspireclass library (Aspire.Hosting9.5.2) withAuthProxyResource : ContainerResourcepointing atcratis/authproxyand a full set of fluent extension methods onIResourceBuilder<T> where T : IResourceWithEnvironment— works on both container and project resourcesAvailable methods:
AddAuthProxy,WithBackend,WithFrontend,WithOidcProvider,WithOAuthProvider,WithHostTenantResolution,WithSubHostTenantResolution,WithClaimTenantResolution,WithRouteTenantResolution,WithSpecifiedTenantResolution,WithDefaultTenantResolution,WithSelectionTenantResolution,WithTenantVerification,WithInvite,WithInviteClaimForwarding,WithLobbyFrontend,WithLobbyBackendOidcProviderTypeenum (Custom,Microsoft,Google,GitHub,Apple) in the Aspire library — standalone, no dependency on the AuthProxy web projectDocumentation/aspire/index.md— how-to guide covering container vs project resource setup, allWith*extension methods, theOidcProviderTypeenum, tenant selection, invites & lobby, identity details resolution, resource-based endpoint references, and cross-links to the existing configuration referencepublish-nugetjob in.github/workflows/publish.ymlusing OIDC trusted publishing (NuGet/login@v1) — packs and pushes onlySource/Aspire/Aspire.csprojasCratis.AuthProxy.Aspireto NuGet.org; runs independently of the Docker pipelineChanged
Composition/AppHost.csupdated to useWithBackend/WithFrontendinstead of bareWithReference, and now wires up the frontend (web) service as wellSource/Aspire/Aspire.csprojupdated with full NuGet package metadata (PackageId,Title,Description,Authors,PackageLicenseExpression,RepositoryUrl,PackageTags,IsPackable)WithSelectionTenantResolutionupdated to accept an optionaltenantsEndpointparameter that maps toTenantResolutions[n].Options.TenantsEndpoint, and a new resource-based overload that accepts anIResourceBuilder<IResourceWithEndpoints>+ route so Aspire resolves the base URL automaticallyWithTenantVerificationgains a resource-based overload — pass an Aspire service resource and a route template instead of a full URLWithInvitegains a resource-based overload — pass the exchange service resource and route instead of a hardcoded exchange URLWithBackendgains an optionalresolveIdentityDetailsparameter (bool?) that maps toServices[name].ResolveIdentityDetails, controlling whether AuthProxy calls/.cratis/meon that service's backend to enrich the identity cookie