Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
14 changes: 14 additions & 0 deletions Microsoft.AspNetCore.SystemWebAdapters.sln
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthWindowsCore", "samples\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.ServiceDefaults", "samples\ServiceDefaults\Samples.ServiceDefaults.csproj", "{D08809BC-D4C3-F7C8-1C00-151CA8C6E504}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.IncrementalMigration", "src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj", "{0D10989D-058E-5684-7828-C5A12A0DC0C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Microsoft.AspNetCore.SystemWebAdapters", "src\Aspire.Microsoft.AspNetCore.SystemWebAdapters\Aspire.Microsoft.AspNetCore.SystemWebAdapters.csproj", "{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -246,6 +250,14 @@ Global
{D08809BC-D4C3-F7C8-1C00-151CA8C6E504}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D08809BC-D4C3-F7C8-1C00-151CA8C6E504}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D08809BC-D4C3-F7C8-1C00-151CA8C6E504}.Release|Any CPU.Build.0 = Release|Any CPU
{0D10989D-058E-5684-7828-C5A12A0DC0C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D10989D-058E-5684-7828-C5A12A0DC0C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D10989D-058E-5684-7828-C5A12A0DC0C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D10989D-058E-5684-7828-C5A12A0DC0C2}.Release|Any CPU.Build.0 = Release|Any CPU
{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -290,6 +302,8 @@ Global
{AC29CA1D-A850-4C29-B27D-C23BAF3D664C} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
{64B09008-C9CB-BAEC-2AE1-616E6BE9880B} = {AC29CA1D-A850-4C29-B27D-C23BAF3D664C}
{D08809BC-D4C3-F7C8-1C00-151CA8C6E504} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
{0D10989D-058E-5684-7828-C5A12A0DC0C2} = {F9DB9323-C919-49E8-8F96-B923D2F42E60}
{B955861A-DDDE-0D3F-B0AC-3D6CAA95A0A5} = {F9DB9323-C919-49E8-8F96-B923D2F42E60}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DABA3C65-9D74-4EB6-9B1C-730328710EAD}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" />

Expand All @@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\AuthRemoteFormsAuthCore\AuthRemoteFormsAuthCore.csproj" />
<ProjectReference Include="..\AuthRemoteFormsAuthFramework\AuthRemoteFormsAuthFramework.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
var builder = DistributedApplication.CreateBuilder(args);

var remoteApiKey = builder.AddParameter("apiKey", Guid.NewGuid().ToString(), secret: true);

var frameworkApp = builder.AddIISExpress("iis")
.AddSiteProject<Projects.AuthRemoteFormsAuthFramework>("framework")
.WithDefaultIISExpressEndpoints()
.WithOtlpExporter()
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithHttpHealthCheck();

var coreApp = builder.AddProject<Projects.AuthRemoteFormsAuthCore>("core")
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithReference(frameworkApp)
.WithEnvironment("RemoteApp__Url", frameworkApp.GetEndpoint("https"))
.WithHttpHealthCheck()
.WaitFor(frameworkApp);
.WaitFor(frameworkApp)
.WithIncrementalMigrationFallback(frameworkApp, options => options.RemoteAuthentication = RemoteAuthentication.DefaultScheme);

builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.csproj" />
</ItemGroup>
Expand Down
22 changes: 3 additions & 19 deletions samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthCore/Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.AddSystemWebAdapters();

builder.Services.AddReverseProxy();

// Add services to the container.
builder.Services.AddControllersWithViews();

// Add System.Web adapter services, including registering remote app authentication
builder.Services.AddSystemWebAdapters()
.AddRemoteAppClient(options =>
{
options.RemoteAppUrl = new(builder.Configuration["RemoteApp:Url"]!);
options.ApiKey = builder.Configuration["RemoteApp:ApiKey"]!;
})
.AddAuthenticationClient(true);

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand All @@ -40,13 +29,8 @@
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

// Configure the reverse proxy to forward all unhandled requests to the remote app
app.MapForwarder("/{**catch-all}", app.Configuration["RemoteApp:Url"]!)

// If there is a route locally, we want to ensure that is used by default, but otherwise we'll forward
.WithOrder(int.MaxValue)
app.MapDefaultEndpoints();

// If we're going to forward the request, there is no need to run any of the middleware after routing
.ShortCircuit();
app.MapRemoteAppFallback();

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ protected void Application_Start()
builder.AddServiceDefaults();
builder.RegisterWebObjectActivator();

builder.Services.AddSystemAdapters()
.AddVirtualizedContentDirectories()
.AddProxySupport(options => options.UseForwardedHeaders = true)
.AddRemoteAppServer(builder.Configuration.GetSection("RemoteApp").Bind)
.AddAuthenticationServer();
builder.AddSystemWebAdapters()
.AddVirtualizedContentDirectories();
});

RouteConfig.RegisterRoutes(RouteTable.Routes);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" />

Expand All @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\AuthRemoteIdentityCore\AuthRemoteIdentityCore.csproj" />
<ProjectReference Include="..\AuthRemoteIdentityFramework\AuthRemoteIdentityFramework.csproj" />
</ItemGroup>
Expand Down
13 changes: 4 additions & 9 deletions samples/AuthRemoteIdentity/AuthRemoteIdentityAppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@

var builder = DistributedApplication.CreateBuilder(args);

var remoteApiKey = builder.AddParameter("apiKey", Guid.NewGuid().ToString(), secret: true);

var iisExpress = builder.AddIISExpress("iis");

var db = builder.AddSqlServer("identityserver")
.WithLifetime(ContainerLifetime.Persistent)
.AddDatabase("identity");

var frameworkApp = iisExpress.AddSiteProject<Projects.AuthRemoteIdentityFramework>("framework")
var frameworkApp = builder.AddIISExpress("iis")
.AddSiteProject<Projects.AuthRemoteIdentityFramework>("framework")
.WithDefaultIISExpressEndpoints()
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithReference(db, connectionName: "DefaultConnection")
.WithOtlpExporter()
.WaitFor(db)
.WithHttpHealthCheck();

var coreApp = builder.AddProject<Projects.AuthRemoteIdentityCore>("core")
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithEnvironment("RemoteApp__Url", frameworkApp.GetEndpoint("https"))
.WithHttpHealthCheck()
.WaitFor(frameworkApp);
.WaitFor(frameworkApp)
.WithIncrementalMigrationFallback(frameworkApp, options => options.RemoteAuthentication = RemoteAuthentication.DefaultScheme);

builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SystemWebAdapters.Authentication;
using MvcCoreApp.Models;
using System.Diagnostics;

Expand All @@ -24,7 +26,7 @@ public IActionResult Privacy()
return View();
}

[Authorize(AuthenticationSchemes = "Remote")]
[Authorize(AuthenticationSchemes = RemoteAppAuthenticationDefaults.AuthenticationScheme)]
public IActionResult UserInfo()
{
return View();
Expand Down
19 changes: 2 additions & 17 deletions samples/AuthRemoteIdentity/AuthRemoteIdentityCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
var builder = WebApplication.CreateBuilder();

builder.AddServiceDefaults();
builder.AddSystemWebAdapters();

// These must match the data protection settings in MvcApp Startup.Auth.cs for cookie sharing to work
var sharedApplicationName = "CommonMvcAppName";
Expand All @@ -27,17 +28,8 @@
builder.Services.AddAuthentication()
.AddCookie("SharedCookie", options => options.Cookie.Name = ".AspNet.ApplicationCookie");

builder.Services.AddReverseProxy();

// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddSystemWebAdapters()
.AddRemoteAppClient(options =>
{
options.RemoteAppUrl = new(builder.Configuration["RemoteApp:Url"]!);
options.ApiKey = builder.Configuration["RemoteApp:ApiKey"]!;
})
.AddAuthenticationClient(true);

var app = builder.Build();

Expand All @@ -61,13 +53,6 @@

app.MapDefaultControllerRoute();

// Configure the the reverse proxy to forward all unhandled requests to the remote app
app.MapForwarder("/{**catch-all}", app.Configuration["RemoteApp:Url"]!)

// If there is a route locally, we want to ensure that is used by default, but otherwise we'll forward
.WithOrder(int.MaxValue)

// If we're going to forward the request, there is no need to run any of the middleware after routing
.ShortCircuit();
app.MapRemoteAppFallback();

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ protected void Application_Start()
builder.AddServiceDefaults();
builder.RegisterWebObjectActivator();

builder.Services.AddSystemAdapters()
.AddVirtualizedContentDirectories()
.AddProxySupport(options => options.UseForwardedHeaders = true)
.AddRemoteAppServer(builder.Configuration.GetSection("RemoteApp").Bind)
.AddAuthenticationServer();
builder.AddSystemWebAdapters()
.AddVirtualizedContentDirectories();
});

AreaRegistration.RegisterAllAreas();
Expand Down
5 changes: 2 additions & 3 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Antlr" Version="3.5.0.2" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.3.0" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.3.1" />
<PackageVersion Include="Aspire.Hosting.SqlServer" Version="9.3.0" />
<PackageVersion Include="AspNet.ScriptManager.bootstrap" Version="5.2.3" />
<PackageVersion Include="AspNet.ScriptManager.jQuery" Version="3.7.1" />
Expand Down Expand Up @@ -61,6 +61,5 @@
<PackageVersion Include="System.Security.AccessControl" Version="6.0.1" />
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageVersion Include="WebGrease" Version="1.6.0" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.2.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="../MachineKeyCore/MachineKeyCore.csproj" />
<ProjectReference Include="../MachineKeyFramework/MachineKeyFramework.csproj" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions samples/Modules/ModulesAppHost/ModulesAppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="../ModulesCore/ModulesCore.csproj" />
<ProjectReference Include="../ModulesFramework/ModulesFramework.csproj" />
</ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions samples/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Options;



#if NET
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -126,13 +130,13 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");
app.MapHealthChecks("/health").ShortCircuit();
Copy link
Member

Choose a reason for hiding this comment

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

Might be a dumb question but won't this be already part of the above call to configure http clients where we add the standard resilience handler?


// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}).ShortCircuit();
}

return app;
Expand Down
7 changes: 4 additions & 3 deletions samples/ServiceDefaults/Samples.ServiceDefaults.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />

<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SystemWebAdapters.CoreServices\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.csproj" />

<Compile Remove="Framework/**/*" />
</ItemGroup>

Expand All @@ -33,7 +31,10 @@
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" />
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Aspire.Microsoft.AspNetCore.SystemWebAdapters\Aspire.Microsoft.AspNetCore.SystemWebAdapters.csproj" />
</ItemGroup>

</Project>
8 changes: 2 additions & 6 deletions samples/SessionRemote/SessionRemoteAppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
var builder = DistributedApplication.CreateBuilder(args);

var remoteApiKey = builder.AddParameter("apiKey", Guid.NewGuid().ToString(), secret: true);

var frameworkApp = builder.AddIISExpress("iis")
.AddSiteProject<Projects.SessionRemoteFramework>("framework")
.WithDefaultIISExpressEndpoints()
.WithOtlpExporter()
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithHttpHealthCheck(path: "/framework");

var coreApp = builder.AddProject<Projects.SessionRemoteCore>("core")
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithEnvironment("RemoteApp__Url", frameworkApp.GetEndpoint("https"))
.WithHttpHealthCheck()
.WaitFor(frameworkApp);
.WaitFor(frameworkApp)
.WithIncrementalMigrationFallback(frameworkApp, options => options.RemoteSession = RemoteSession.Enabled);

builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Hosting.IncrementalMigration\Aspire.Hosting.IncrementalMigration.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\SessionRemoteCore\SessionRemoteCore.csproj" />
<ProjectReference Include="..\SessionRemoteFramework\SessionRemoteFramework.csproj" />
</ItemGroup>
Expand Down
Loading