What is the correct way to share the login cookie with an asp.net core application?
I've got a single application running behind multiple subdomains i.e :
- site1.mydomain.com
- site2.mydomain.com
and I can't get the authentication to persist across both.
I have the startup.cs configured in the following manner and this allows me to authenticate via google :
app.UseIdentity();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = new PathString("/account/login"),
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
CookieDomain = ".mydomain.com",
CookieName = "AuthenticationCookie"
});
app.UseGoogleAuthentication(options =>
{
options.ClientId = "xxx";
options.ClientSecret = "xxx";
});
I also believe I correctly setup the data protection services because I currently have the site running in multiple docker containers and the application can successfully load balance.
What is confusing me is when I inspect the cookies set by the authentication process it always has the site1.mydomain.com logged against the authentication cookie and not .mydomain.
It's like the cookiedomain is being ignored during the authentication process.
Any pointers would be gratefully received.