I have many application which is hosted on main domain and sub domains:
Website A, ASP.NET (.Net Core 2.0) at www.example.com
Website B, ASP.NET MVC (4.7 .net Framework) at site.example.com
Website C, ASP.NET Identity (.Net Core 2.0) at account.example.com
Website D, ASP.NET Webform (4.7 .net Framework) at file.example.com
I would like to login uses on account.example.com, after authenticate users will redirected to other websites. They will be authorize by there roles on other websites.
I'm trying to share a cookie between these websites and all of the website are hosted on Azure Web App.
I am using ASP.NET Identity (.Net Core 2.0). I'm using the built-in cookie authentication.
How can I use Data Protection in all application and share cookie among them.
For Data Protection my code is:
services.AddDataProtection()
.SetApplicationName("example")
.PersistKeysToFileSystem(new DirectoryInfo(@"%HOME%\ASP.NET\DataProtection-Keys"))
.SetDefaultKeyLifetime(TimeSpan.FromDays(14));
For Cookie Authentication my code is:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieDomain = ".example.com"
});