I have an ASP.NET Core 2.2 application running in a B1 instance in Azure App Services. If I log into the website, and open it on another machine, I am logged in on that machine too, including access to all pages protected by Authorization. When I log out on the second machine I'm not automatically logged back in until I clear the browser cache and restart the browser.
A similar issue was described here, but was never really answered: ASP.NET Core identity shared across browser
This behavior seems to be somehow related to be running in an Azure App Service (Linux). I had the site running in a Docker image on a normal Linux VM (Ubuntu 18.04, official MS Docker image) before, and did not encounter this problem.
Here is all code from Startup.cs that could be relevant:
public void ConfigureServices(IServiceCollection services)
{
[...]
services.Configure<CookiePolicyOptions>(
options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = _ => false;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
[...]
services.AddIdentity<User, IdentityRole>()
.AddErrorDescriber<TopikonIdentityErrorDescriber>()
.AddEntityFrameworkStores<TopikonContext>()
.AddDefaultTokenProviders();
services.AddAuthentication();
services.AddAuthorization(
options =>
{
options.AddPolicy(
TopikonPolicies.ControlPanel,
policy => policy
.RequireRole(TopikonRoles.ControlCenterAccess));
});
services .AddMvc()
.AddRazorPagesOptions(
options =>
{
options.AllowAreas = true;
options.Conventions.AuthorizeFolder("/");
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
[...] }
public static void Configure(IApplicationBuilder app, IHostingEnvironment env){
[...]
app.UseCookiePolicy();
app.UseAuthentication();
app.UseSession();
app.UseMvc();
}
App Service Authentication is switched on and set to "Allow Anonymous". I tried switching it off, but the result was the same. I'd like users to be logged in only on the machine they are using, and not to provide their login to everyone visiting the site. Unfortunately I'm not quite sure where to look for answers.