Add a discriminator so that DataProtection doesn't use the same subkey across apps by default.
This commit is contained in:
parent
c859c3dad5
commit
ebe4948a3e
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.Security.DataProtection;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||||
|
|
@ -46,6 +47,14 @@ namespace Microsoft.AspNet.Hosting
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.Add(HostingServices.GetDefaultServices(config));
|
serviceCollection.Add(HostingServices.GetDefaultServices(config));
|
||||||
serviceCollection.AddInstance<IHostingEnvironment>(hostingEnv);
|
serviceCollection.AddInstance<IHostingEnvironment>(hostingEnv);
|
||||||
|
// The application name is a "good enough" mechanism to identify this application
|
||||||
|
// on the machine and to prevent subkeys from being shared across multiple applications
|
||||||
|
// by default.
|
||||||
|
serviceCollection.ConfigureOptions<DataProtectionOptions>(options =>
|
||||||
|
{
|
||||||
|
options.ApplicationDiscriminator = appEnv.ApplicationName;
|
||||||
|
});
|
||||||
|
|
||||||
var services = serviceCollection.BuildServiceProvider(_serviceProvider);
|
var services = serviceCollection.BuildServiceProvider(_serviceProvider);
|
||||||
|
|
||||||
var context = new HostingContext()
|
var context = new HostingContext()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue