Browse Source

Set data protection application discriminators

This prevents cookie confusion when applications are hosted at the same domain and path. For example, under default settings, WebMVC may attempt to decrypt Identity's antiforgery cookie rather than its own.
pull/142/head
Charles Lowell 8 years ago
parent
commit
2f3df2715d
3 changed files with 15 additions and 0 deletions
  1. +5
    -0
      src/Services/Identity/Identity.API/Startup.cs
  2. +5
    -0
      src/Web/WebMVC/Startup.cs
  3. +5
    -0
      src/Web/WebSPA/Startup.cs

+ 5
- 0
src/Services/Identity/Identity.API/Startup.cs View File

@ -54,6 +54,11 @@ namespace eShopOnContainers.Identity
services.Configure<AppSettings>(Configuration); services.Configure<AppSettings>(Configuration);
services.AddDataProtection(opts =>
{
opts.ApplicationDiscriminator = "eshop.identity";
});
services.AddMvc(); services.AddMvc();
services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<IEmailSender, AuthMessageSender>();


+ 5
- 0
src/Web/WebMVC/Startup.cs View File

@ -42,6 +42,11 @@ namespace Microsoft.eShopOnContainers.WebMVC
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddDataProtection(opts =>
{
opts.ApplicationDiscriminator = "eshop.webmvc";
});
services.AddMvc(); services.AddMvc();
services.Configure<AppSettings>(Configuration); services.Configure<AppSettings>(Configuration);


+ 5
- 0
src/Web/WebSPA/Startup.cs View File

@ -41,6 +41,11 @@ namespace eShopConContainers.WebSPA
{ {
services.Configure<AppSettings>(Configuration); services.Configure<AppSettings>(Configuration);
services.AddDataProtection(opts =>
{
opts.ApplicationDiscriminator = "eshop.webspa";
});
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN"); services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
services.AddMvc() services.AddMvc()


Loading…
Cancel
Save