Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How those app share cookies ? #7392

Closed
John0King opened this issue Jun 30, 2018 — with docs.microsoft.com · 9 comments
Closed

How those app share cookies ? #7392

John0King opened this issue Jun 30, 2018 — with docs.microsoft.com · 9 comments
Assignees
Labels
Pri2 Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

I'm confusing with this doc, AFAK cookies has domain , and there nowhere to configurate , and if they live in differenct sub domain , how can the cookie be shared ?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@guardrex
Copy link
Collaborator

guardrex commented Jun 30, 2018

@HaoK Is it correct that if SameSite is set to Lax (the default) that it doesn't matter if the hostname is defaulted into the Cookie.Domain property as long as the Cookie.Name is set to a common value?

FYI: The content on this API page is broken: https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.authentication.cookies.cookieauthenticationoptions.cookie ... it's not piping the CookieBuilder prop names thru to the page, so the sentences are broken.

@guardrex guardrex added the Source - Docs.ms Docs Customer feedback via GitHub Issue label Jun 30, 2018
@guardrex guardrex self-assigned this Jun 30, 2018
@guardrex guardrex added this to the Backlog milestone Jun 30, 2018
@HaoK
Copy link
Member

HaoK commented Jul 5, 2018

@Tratcher can you answer @guardrex ?

@Tratcher
Copy link
Member

Tratcher commented Jul 5, 2018

SameSite appears to require exact domain matches. Lax only skips the domain check for top-level interactions like a user link click.

As for sharing cookies across subdomains, the most common guidance seems to be to set the domain to the parent domain like ".example.com".

@guardrex
Copy link
Collaborator

guardrex commented Jul 5, 2018

In that case, we should add a piece here on setting Cookie.Domain.

@serfend
Copy link

serfend commented Apr 17, 2019

why the request still appear to be samesite=true on the configure below

public void ConfigureServices(IServiceCollection services)
        {

			services.AddDbContext<ApplicationDbContext>(options=>{
				var connectionString = Configuration.GetConnectionString("DefaultConnection");
				options.UseLazyLoadingProxies()
					   .UseSqlServer(connectionString);
			});
			services.AddCors(options =>
			{
				options.AddPolicy(MyAllowSpecificOrigins,
					builder =>
					{
						builder.AllowAnyHeader().AllowAnyMethod().AllowCredentials().SetIsOriginAllowed((x) =>
						{
							return true;
						});
					});
			});
			services.AddAuthentication()
				.AddCookie(options =>
				{
					options.Cookie.SameSite = SameSiteMode.None;
				});
			services.AddSession(s => s.IdleTimeout = TimeSpan.FromMinutes(60));

			services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();


            services.Configure<IdentityOptions>(options =>
            {
                // Password settings
                options.Password.RequireDigit = true;
                options.Password.RequiredLength = 8;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase = true;
                options.Password.RequireLowercase = false;
                options.Password.RequiredUniqueChars = 4;

                // Lockout settings
                options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30);
                options.Lockout.MaxFailedAccessAttempts = 10;
                options.Lockout.AllowedForNewUsers = true;

                // User settings
                options.User.RequireUniqueEmail = true;
            });

  
            AddApplicationServices(services);
            
          
			services.AddMvc();

		}

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services, ApplicationDbContextSeeder seeder) 
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else if(env.IsProduction())
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHttpsRedirection();
            }
           
			app.UseWelcomePage(new WelcomePageOptions() {
				Path="/welcome"
			});
            app.UseStaticFiles();

			app.UseCors(MyAllowSpecificOrigins);
			app.UseAuthentication();
			app.UseCookiePolicy(new CookiePolicyOptions()
			{
				MinimumSameSitePolicy = SameSiteMode.None,
			});


			app.UseSession();

			app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
					//controller/action/param
                    template: "{controller=Home}/{action=Cover}/{id?}");
            });

            //seeder.Seed().Wait();
            //seeder.CreateUserRoles(services).Wait();

        }

@guardrex
Copy link
Collaborator

Hello @serfend ... We only handle documentation issues. For general support, ask on a support forum, such as Stack Overflow, or a support chat, such as Slack or Gitter.

Also note that we don't work closed issues. For a new documentation issue, we ask that readers use the feedback buttons at the bottoms of the topics to open new issues.

@Tratcher
Copy link
Member

@serfend see dotnet/aspnetcore#4647, you likely need ConfigureExternalCookie and ConfigureApplicationCookie.

@serfend
Copy link

serfend commented Apr 17, 2019

@Tratcher i tried ,but it only work on .AspNetCore.Identity.Application
the other cookie .AspNetCore.Session still contains samesite=lax

@Tratcher
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pri2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

5 participants