Skip to content

Commit bf4f929

Browse files
authored
Add OWIN integration (#621)
This enables a number of scenarios that make migrating Owin usage a bit easier: - Simplifies adding owin pipelines into the ASP.NET Core pipeline - Adds an authentication handler that wraps the Owin IAuthentication handler - Enabled adding Owin pipeline to the HttpApplication pipeline like in System.Web
1 parent 0860790 commit bf4f929

File tree

71 files changed

+2628
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2628
-535
lines changed

Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
-->
4848
<NoWarn>$(NoWarn);SYSWEB1001</NoWarn>
4949

50+
<!-- Suppress warning for using .NET Framework packages -->
51+
<NoWarn>$(NoWarn);NU1701</NoWarn>
52+
5053
<!-- We want to run pack on the solution so this allows us to do that -->
5154
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
5255
</PropertyGroup>

Microsoft.AspNetCore.SystemWebAdapters.sln

Lines changed: 0 additions & 366 deletions
This file was deleted.

Microsoft.AspNetCore.SystemWebAdapters.slnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"solution": {
3-
"path": "Microsoft.AspNetCore.SystemWebAdapters.sln",
3+
"path": "Microsoft.AspNetCore.SystemWebAdapters.slnx",
44
"projects": [
55
"src\\Microsoft.AspNetCore.SystemWebAdapters.Abstractions\\Microsoft.AspNetCore.SystemWebAdapters.Abstractions.csproj",
66
"src\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.csproj",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<Solution>
2+
<Folder Name="/samples/">
3+
<File Path="samples/Directory.Build.props" />
4+
<File Path="samples/Directory.Build.targets" />
5+
<File Path="samples/Directory.Packages.props" />
6+
<File Path="samples/README.md" />
7+
<Project Path="samples/ServiceDefaults/Samples.ServiceDefaults.csproj" />
8+
</Folder>
9+
<Folder Name="/samples/AppConfig/">
10+
<Project Path="samples/AppConfig/AppConfigAppHost/AppConfigAppHost.csproj" />
11+
<Project Path="samples/AppConfig/AppConfigCore/AppConfigCore.csproj" />
12+
<Project Path="samples/AppConfig/AppConfigFramework/AppConfigFramework.csproj" />
13+
</Folder>
14+
<Folder Name="/samples/AuthRemoteFormsAuth/">
15+
<Project Path="samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthAppHost/AuthRemoteFormsAuthAppHost.csproj" />
16+
<Project Path="samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthCore/AuthRemoteFormsAuthCore.csproj" />
17+
<Project Path="samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthFramework/AuthRemoteFormsAuthFramework.csproj" />
18+
</Folder>
19+
<Folder Name="/samples/AuthRemoteIdentity/">
20+
<Project Path="samples/AuthRemoteIdentity/AuthRemoteIdentityAppHost/AuthRemoteIdentityAppHost.csproj" />
21+
<Project Path="samples/AuthRemoteIdentity/AuthRemoteIdentityCore/AuthRemoteIdentityCore.csproj" />
22+
<Project Path="samples/AuthRemoteIdentity/AuthRemoteIdentityFramework/AuthRemoteIdentityFramework.csproj" />
23+
</Folder>
24+
<Folder Name="/samples/AuthWindows/">
25+
<Project Path="samples/AuthWindows/AuthWindowsCore/AuthWindowsCore.csproj" />
26+
</Folder>
27+
<Folder Name="/samples/DependencyInjection/">
28+
<Project Path="samples/DependencyInjection/DependencyInjectionAppHost/DependencyInjectionAppHost.csproj" />
29+
<Project Path="samples/DependencyInjection/DependencyInjectionFramework/DependencyInjectionFramework.csproj" />
30+
</Folder>
31+
<Folder Name="/samples/MachineKey/">
32+
<Project Path="samples/MachineKey/MachineKeyAppHost/MachineKeyAppHost.csproj" />
33+
<Project Path="samples/MachineKey/MachineKeyCore/MachineKeyCore.csproj" />
34+
<Project Path="samples/MachineKey/MachineKeyFramework/MachineKeyFramework.csproj" />
35+
<Project Path="samples/MachineKey/MachineKeyShared/MachineKeyShared.csproj" />
36+
</Folder>
37+
<Folder Name="/samples/Modules/">
38+
<Project Path="samples/Modules/ModulesAppHost/ModulesAppHost.csproj" />
39+
<Project Path="samples/Modules/ModulesCore/ModulesCore.csproj" />
40+
<Project Path="samples/Modules/ModulesFramework/ModulesFramework.csproj" />
41+
<Project Path="samples/Modules/ModulesLibrary/ModulesLibrary.csproj" />
42+
</Folder>
43+
<Folder Name="/samples/SessionRemote/">
44+
<Project Path="samples/SessionRemote/SessionRemoteAppHost/SessionRemoteAppHost.csproj" />
45+
<Project Path="samples/SessionRemote/SessionRemoteCore/SessionRemoteCore.csproj" />
46+
<Project Path="samples/SessionRemote/SessionRemoteFramework/SessionRemoteFramework.csproj" />
47+
</Folder>
48+
<Folder Name="/samples/WebFormsToBlazor/">
49+
<Project Path="samples/WebFormsToBlazor/WebFormsToBlazorAppHost/WebFormsToBlazorAppHost.csproj" />
50+
<Project Path="samples/WebFormsToBlazor/WebFormsToBlazorCore/WebFormsToBlazorCore.csproj" />
51+
<Project Path="samples/WebFormsToBlazor/WebFormsToBlazorFramework/WebFormsToBlazorFramework.csproj" />
52+
</Folder>
53+
<Folder Name="/Solution Items/">
54+
<File Path=".editorconfig" />
55+
<File Path="Directory.Build.props" />
56+
<File Path="Directory.Build.targets" />
57+
<File Path="global.json" />
58+
<File Path="NuGet.config" />
59+
<File Path="README.md" />
60+
</Folder>
61+
<Folder Name="/src/">
62+
<File Path="src/Directory.Build.props" />
63+
<File Path="src/Directory.Build.targets" />
64+
<File Path="src/Directory.Packages.props" />
65+
<Project Path="src/Aspire.Hosting.IncrementalMigration/Aspire.Hosting.IncrementalMigration.csproj" />
66+
<Project Path="src/Aspire.Microsoft.AspNetCore.SystemWebAdapters/Aspire.Microsoft.AspNetCore.SystemWebAdapters.csproj" />
67+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.Abstractions/Microsoft.AspNetCore.SystemWebAdapters.Abstractions.csproj" />
68+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.Analyzers.CSharp/Microsoft.AspNetCore.SystemWebAdapters.Analyzers.CSharp.csproj" />
69+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.Analyzers/Microsoft.AspNetCore.SystemWebAdapters.Analyzers.csproj" />
70+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.csproj" />
71+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.csproj" />
72+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters.Owin/Microsoft.AspNetCore.SystemWebAdapters.Owin.csproj" />
73+
<Project Path="src/Microsoft.AspNetCore.SystemWebAdapters/Microsoft.AspNetCore.SystemWebAdapters.csproj" />
74+
</Folder>
75+
<Folder Name="/test/">
76+
<File Path="test/Directory.Build.props" />
77+
<File Path="test/Directory.Build.targets" />
78+
<File Path="test/Directory.Packages.props" />
79+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.Apis.Tests/Microsoft.AspNetCore.SystemWebAdapters.Apis.Tests.csproj" />
80+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests.csproj" />
81+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.E2E.Tests/Microsoft.AspNetCore.SystemWebAdapters.E2E.Tests.csproj" />
82+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests.csproj" />
83+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests/Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests.csproj" />
84+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.Owin.Tests/Microsoft.AspNetCore.SystemWebAdapters.Owin.Tests.csproj" />
85+
<Project Path="test/Microsoft.AspNetCore.SystemWebAdapters.Tests/Microsoft.AspNetCore.SystemWebAdapters.Tests.csproj" />
86+
</Folder>
87+
</Solution>

samples/AppConfig/AppConfigFramework/Web.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<connectionStrings>
44
<add name="ConnStr1" connectionString="web.config" />
@@ -113,8 +113,8 @@
113113
</assemblyBinding>
114114
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
115115
<dependentAssembly>
116-
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
117-
<bindingRedirect oldVersion="0.0.0.0-8.0.14.0" newVersion="8.0.14.0" />
116+
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" culture="neutral" publicKeyToken="adb9793829ddae60" />
117+
<bindingRedirect oldVersion="0.0.0.0-8.0.16.0" newVersion="8.0.16.0" />
118118
</dependentAssembly>
119119
</assemblyBinding>
120120
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@@ -160,4 +160,4 @@
160160
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
161161
</compilers>
162162
</system.codedom>
163-
</configuration>
163+
</configuration>

samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthFramework/AuthRemoteFormsAuthFramework.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
<PackageReference Include="Microsoft.AspNet.ScriptManager.MSAjax" GeneratePathProperty="true" CopyContent="true" />
99
<PackageReference Include="Microsoft.AspNet.ScriptManager.WebForms" GeneratePathProperty="true" CopyContent="true" />
1010
<PackageReference Include="Microsoft.AspNet.Web.Optimization.WebForms" NoWarn="NU1602" />
11-
<PackageReference Include="Microsoft.Configuration.ConfigurationBuilders.Environment" />
1211
<PackageReference Include="Newtonsoft.Json" />
1312
<PackageReference Include="WebGrease" />
1413
<PackageReference Include="Microsoft.Web.Infrastructure" />
1514
</ItemGroup>
1615
<ItemGroup>
1716
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.csproj" />
1817
</ItemGroup>
19-
<ItemGroup>
20-
<Reference Include="System.Configuration" />
21-
</ItemGroup>
2218
</Project>

samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthFramework/Web.config

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<configSections>
4-
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
5-
</configSections>
6-
<configBuilders>
7-
<builders>
8-
<add name="AS_Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment" />
9-
</builders>
10-
</configBuilders>
11-
<appSettings configBuilders="AS_Environment">
12-
<!-- Populated by the configBuilder. NOTE: Key must be present or it will not be populated -->
13-
<add key="RemoteApp__ApiKey" value="" />
14-
</appSettings>
153
<system.web>
164
<compilation debug="true" targetFramework="4.8.1" />
175
<httpRuntime targetFramework="4.8.1" />
@@ -130,8 +118,8 @@
130118
</assemblyBinding>
131119
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
132120
<dependentAssembly>
133-
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" publicKeyToken="adb9793829ddae60" culture="neutral" />
134-
<bindingRedirect oldVersion="0.0.0.0-8.0.14.0" newVersion="8.0.14.0" />
121+
<assemblyIdentity name="Microsoft.Extensions.ObjectPool" culture="neutral" publicKeyToken="adb9793829ddae60" />
122+
<bindingRedirect oldVersion="0.0.0.0-8.0.16.0" newVersion="8.0.16.0" />
135123
</dependentAssembly>
136124
</assemblyBinding>
137125
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

samples/AuthRemoteIdentity/AuthRemoteIdentityAppHost/AuthRemoteIdentityAppHost.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
1010
<IsAspireHost>true</IsAspireHost>
11+
<UserSecretsId>e4fa25b4-d989-447b-bf65-a59df2252e69</UserSecretsId>
12+
<LangVersion>14</LangVersion>
1113
</PropertyGroup>
1214

1315
<ItemGroup>

samples/AuthRemoteIdentity/AuthRemoteIdentityAppHost/Program.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
using System.Security.Policy;
2+
using Microsoft.AspNetCore.DataProtection.KeyManagement;
23
using Microsoft.Extensions.Configuration;
34

45
var builder = DistributedApplication.CreateBuilder(args);
56

6-
var db = builder.AddSqlServer("identityserver")
7+
var password = builder.AddParameter("sqlPass", secret: true);
8+
var apiKey = builder.AddParameter("remoteapp-apiKey", () => Guid.NewGuid().ToString(), secret: true);
9+
10+
var db = builder.AddSqlServer("identityserver", password: password)
11+
// Configure the container to store data in a volume so that it persists across instances.
12+
.WithDataVolume()
13+
// Keep the container running between app host sessions.
714
.WithLifetime(ContainerLifetime.Persistent)
815
.AddDatabase("identity");
916

@@ -15,9 +22,24 @@
1522
.WaitFor(db)
1623
.WithHttpHealthCheck();
1724

25+
var owin = builder.AddProject<Projects.AuthRemoteIdentityCore>("owin")
26+
.WithHttpEndpoint(targetPort: 5000)
27+
.WithHttpsEndpoint(targetPort: 5001)
28+
.WithHttpHealthCheck("/health")
29+
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
30+
.WithEnvironment("SAMPLE_MODE", "OWIN")
31+
.WithReference(db, connectionName: "DefaultConnection")
32+
.WithIncrementalMigrationFallback(frameworkApp, apiKey: apiKey)
33+
.WaitFor(frameworkApp)
34+
.WaitFor(db);
35+
1836
var coreApp = builder.AddProject<Projects.AuthRemoteIdentityCore>("core")
19-
.WithHttpHealthCheck()
37+
.WithHttpEndpoint(targetPort: 5002)
38+
.WithHttpsEndpoint(targetPort: 5003)
39+
.WithHttpHealthCheck("/health")
40+
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
41+
.WithEnvironment("SAMPLE_MODE", "REMOTE")
2042
.WaitFor(frameworkApp)
21-
.WithIncrementalMigrationFallback(frameworkApp, options => options.RemoteAuthentication = RemoteAuthentication.DefaultScheme);
43+
.WithIncrementalMigrationFallback(frameworkApp, options => options.RemoteAuthentication = RemoteAuthentication.DefaultScheme, apiKey);
2244

2345
builder.Build().Run();
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
33
<TargetFramework>$(SAMPLES_TFM)</TargetFramework>
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>enable</ImplicitUsings>
6+
7+
<!-- We use aspire to hook things up for multiple configurations and need all control -->
8+
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
69
</PropertyGroup>
710
<ItemGroup>
11+
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.SystemWebAdapters.Owin\Microsoft.AspNetCore.SystemWebAdapters.Owin.csproj" />
812
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.csproj" />
913
</ItemGroup>
14+
<ItemGroup>
15+
<PackageReference Include="EntityFramework" />
16+
<PackageReference Include="Newtonsoft.Json" />
17+
<PackageReference Include="Microsoft.AspNet.Identity.EntityFramework" />
18+
<PackageReference Include="Microsoft.AspNet.Identity.Core" />
19+
<PackageReference Include="Microsoft.AspNet.Identity.Owin" />
20+
<PackageReference Include="Microsoft.Owin.Security.Interop" />
21+
</ItemGroup>
22+
<ItemGroup>
23+
<Compile Include="..\AuthRemoteIdentityFramework\App_Start\IdentityConfig.cs" Link="IdentityConfig.cs" />
24+
<Compile Include="..\AuthRemoteIdentityFramework\Models\IdentityModels.cs" Link="IdentityModels.cs" />
25+
</ItemGroup>
1026
</Project>

0 commit comments

Comments
 (0)