Added DPAPI implementation that works on mono
This commit is contained in:
parent
4077c03a7b
commit
7b4e1fd48e
|
|
@ -37,11 +37,20 @@ namespace Microsoft.AspNet.Hosting
|
|||
Lifecycle = LifecycleKind.Scoped
|
||||
};
|
||||
|
||||
// The default IDataProtectionProvider is a singleton.
|
||||
// Note: DPAPI isn't usable in IIS where the user profile hasn't been loaded, but loading DPAPI
|
||||
// is deferred until the first call to Protect / Unprotect. It's up to an IIS-based host to
|
||||
// replace this service as part of application initialization.
|
||||
yield return describer.Instance<IDataProtectionProvider>(DataProtectionProvider.CreateFromDpapi());
|
||||
if (PlatformHelper.IsMono)
|
||||
{
|
||||
#if NET45
|
||||
yield return describer.Instance<IDataProtectionProvider>(DataProtectionProvider.CreateFromLegacyDpapi());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// The default IDataProtectionProvider is a singleton.
|
||||
// Note: DPAPI isn't usable in IIS where the user profile hasn't been loaded, but loading DPAPI
|
||||
// is deferred until the first call to Protect / Unprotect. It's up to an IIS-based host to
|
||||
// replace this service as part of application initialization.
|
||||
yield return describer.Instance<IDataProtectionProvider>(DataProtectionProvider.CreateFromDpapi());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
<Compile Include="HostingServices.cs" />
|
||||
<Compile Include="IHostingEngine.cs" />
|
||||
<Compile Include="PipelineInstance.cs" />
|
||||
<Compile Include="PlatformHelper.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Server\IServerFactory.cs" />
|
||||
<Compile Include="Server\IServerManager.cs" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
internal static class PlatformHelper
|
||||
{
|
||||
private static Lazy<bool> _isMono = new Lazy<bool>(() => Type.GetType("Mono.Runtime") != null);
|
||||
|
||||
public static bool IsMono
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isMono.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue