2

I have a web app which runs under service.domain.de. For authentication in this app I use Azure AD B2C. In the azure security cookie is for the domain service.domain.de . What can I do to get the security cookie for the domain .domain.de? So with the domain .domain.de the cookie is for the domain.de and all subdomains. The service I wrote in ASP.Net and used Microsoft.Owin.Security library (OpenId).

Saca
  • 10,355
  • 1
  • 34
  • 47
Stefan
  • 555
  • 5
  • 18

1 Answers1

1

When you add CookieAuthentication, you can control the domain via CookieAuthenticationOptions' CookieDomain like so:

app.UseCookieAuthentication(new CookieAuthenticationOptions {
  CookieDomain = "domain.de"
});
Saca
  • 10,355
  • 1
  • 34
  • 47
  • 1
    When I use it. It runs without any errors. But when I return to the my service, after authentication in Azure AD B2C, there is no cookie set. It only works fine wenn I ' app.UseCookieAuthentication(new CookieAuthenticationOptions { CookieDomain = "service.domain.de" });' – Stefan May 30 '17 at 23:04
  • 1
    Did you test this with the deployed site or just with localhost. It will only work in the deployed site provided that it's in that domain or a subdomain of it. – Saca May 31 '17 at 04:49
  • It test it with the deployed site under service.domain.de . When I write CookieDmain = "service.domain.de" it runs fine. By CookieDmain = "domain.de" or CookieDmain = ".domain.de" the cookie will not create. – Stefan May 31 '17 at 06:05