Search code examples
c#asp.net-coreasp.net-core-identity

AAD auth and cookie name?


I am using ASP.Net Core 2.2 MVC.

My startup adds AddAuthentication

I want to be able to configure my cookie which stores the AAD token. I tried to add this code below. But when i run my app in Chrome, I do not see the cookie name in dev tools. Any ideas?

services.ConfigureApplicationCookie(options =>
{
    options.Cookie.Name = "MeAPP";
    options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
    options.SlidingExpiration = true;
});

Solution

  • You can rename the cookie name by :

    services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
    .AddAzureAD(options => Configuration.Bind("AzureAd", options));
    
    services.Configure<CookieAuthenticationOptions>(AzureADDefaults.CookieScheme, options =>
    {
        options.Cookie.Name = "MyCookieName";
    });