Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Microsoft.Owin;
using Microsoft.Owin.Extensions;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.DataProtection;
using Microsoft.Owin.Security.Interop;
using MvcApp;
using MvcApp.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
Expand Down
2 changes: 1 addition & 1 deletion samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<PackageVersion Include="Microsoft.jQuery.Unobtrusive.Validation" Version="3.2.11" />
<PackageVersion Include="Microsoft.Owin.Host.SystemWeb" Version="4.2.2" />
<PackageVersion Include="Microsoft.Owin.Security.Cookies" Version="4.2.2" />
<PackageVersion Include="Microsoft.Owin.Security.Interop" Version="2.1.38" />
<PackageVersion Include="Microsoft.Owin.Security.Interop" Version="2.3.0" />
<PackageVersion Include="Microsoft.Owin.Security.OAuth" Version="4.2.2" />
<PackageVersion Include="Microsoft.Web.Infrastructure" Version="2.0.1" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PackageVersion Include="Yarp.ReverseProxy" Version="2.3.0" />
<PackageVersion Include="Microsoft.Owin" Version="4.2.3" />
<PackageVersion Include="Microsoft.Owin.Security" Version="4.2.3" />
<PackageVersion Include="Microsoft.Owin.Security.Interop" Version="2.3.0" />
<PackageVersion Include="Owin" Version="1.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.DataProtection;
using Microsoft.Owin.Security.Interop;
using Owin;

using AspNetCoreDataProtectionProvider = Microsoft.AspNetCore.DataProtection.IDataProtectionProvider;

namespace Microsoft.Owin.Security.DataProtection;

public static class AppBuilderDataProtectionExtensions
{
public static void SetDataProtectionProvider(this IAppBuilder app, AspNetCoreDataProtectionProvider dataProtectionProvider)
{
ArgumentNullException.ThrowIfNull(app);
ArgumentNullException.ThrowIfNull(dataProtectionProvider);

app.SetDataProtectionProvider(new DataProtectionProviderShim(dataProtectionProvider));
}

private sealed class DataProtectionProviderShim(AspNetCoreDataProtectionProvider other) : IDataProtectionProvider
{
public IDataProtector Create(params string[] purposes) => new DataProtectorShim(other.CreateProtector(purposes));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Owin" />
<PackageReference Include="Microsoft.Owin.Security" />
<PackageReference Include="Microsoft.Owin.Security.Interop" />
<PackageReference Include="Microsoft.AspNetCore.Owin" />
</ItemGroup>

Expand Down
12 changes: 12 additions & 0 deletions src/Microsoft.AspNetCore.SystemWebAdapters.Owin/OwinBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Owin.Builder;
using Microsoft.Owin.BuilderProperties;
using Microsoft.Owin.Security.DataProtection;
using Owin;

namespace Microsoft.AspNetCore.SystemWebAdapters;
Expand All @@ -25,8 +27,18 @@ public static AppFunc Build(AppFunc defaultApp, Action<IAppBuilder, IServiceProv

owinAppProperties.AppName = env.ApplicationName;

AddAspNetCoreDefaults(owinAppBuilder, services);

configure(owinAppBuilder, services);

return owinAppBuilder.Build();
}

private static void AddAspNetCoreDefaults(AppBuilder app, IServiceProvider services)
{
if (!app.Properties.ContainsKey("security.DataProtectionProvider") && services.GetService<DataProtection.IDataProtectionProvider>() is { } dataProtectionProvider)
{
app.SetDataProtectionProvider(dataProtectionProvider);
}
}
}